Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Square root, nth root, arc sin, arc tan, and arc cos functions courtesy of "bi0qaw" (http://dev.bukkit.org/profiles/bi0qaw/)
- #Rotation function courtesy of "Cool3303" (http://dev.bukkit.org/profiles/Cool3303/)
- #These commands should be able to approximate the functions of the number argument passed to them to an accuracy of about {@accuracy}
- #Remember to change your "number accuracy:" in your Skript config file to {@accuracy} for best results.
- Options:
- accuracy: 10 #How accurate should our numbers be? 10 is accurate to 7-10 decimal places usually
- permission: "math.calc" #Permission node required to execute the math commands
- message: "true" #Whether or not to message the results to the player executing the command
- e: 2.7182818284
- pi: 3.14159265358979323846
- #Calculate the square root of a number by exponentiating by 0.5
- Command /sqrt <number>:
- Permission: {@permission}
- Trigger:
- Set {_x} to number-argument
- If {_x} is smaller than 0:
- If {@message} is "true":
- Send "You cannot square root a negative number!"
- Stop
- Set {_x} to {_x}^0.5
- Set {sqrt.value} to {_x}
- If {@message} is "true":
- Send "%{sqrt.value.%player%}%" to player
- #Calculate the nth-root of a number by exponentiating by 1/n
- Command /rt <integer> <number>:
- Permission: {@permission}
- Usage: /rt <root-number> <number>
- Trigger:
- Set {_x} to number-argument-2
- Set {_n} to integer-argument-1
- If {_x} is smaller than 0:
- If {@message} is "true":
- Send "You cannot root a negative number!"
- Stop
- Set {_x} to {_x}^(1/{_n})
- Set {rt.value} to {_x}
- If {@message} is "true":
- Send "%{rt.value.%player%}%" to player
- #Calculate the factorial of a number
- Command /fact <number>:
- Permission: {@permission}
- Trigger:
- Set {_x} to number-argument
- Set {_i} to {_x} - 1
- Loop {_i} times:
- Set {_x} to {_x} * {_i}
- Subtract 1 from {_i}
- Set {fact.value} to {_x}
- If {@message} is "true":
- Send "%{fact.value.%player%}%" to player
- #Calculate the sine of a degree by converting it to radians and looping through a Taylor Series formula
- Command /sin <number>:
- Permission: {@permission}
- Trigger:
- Set {_x} to (number-argument / 180) * {@pi}
- Set {_s} to {_x}
- Loop {@accuracy} times:
- Set {_n} to loop-number * 2 + 1
- Execute console command "/fact %{_n}%"
- Set {_f} to {fact.value}
- Set {_s} to {_s} + (({_x} ^ {_n}) / {_f}) * (-1 ^ loop-number)
- Set {sin.value} to {_s}
- If {@message} is "true":
- Send "%{sin.value}%" to player
- #Calculate the cosine of a degree by converting it to radians and looping through a Taylor Series formula
- Command /cos <number>:
- Permission: {@permission}
- Trigger:
- Set {_x} to (number-argument / 180) * {@pi}
- Set {_c} to 1
- Loop {@accuracy} times:
- Set {_n} to loop-number * 2
- Execute console command "/fact %{_n}%"
- Set {_f} to {fact.value}
- Set {_c} to {_c} + (({_x} ^ {_n}) / {_f}) * (-1 ^ loop-number)
- Set {cos.value} to {_c}
- If {@message} is "true":
- Send "%{cos.value}%" to player
- #Calculate the tangent of a degree
- Command /tan <number>:
- Permission: {@permission}
- Trigger:
- Execute console command "/sin %number-argument%"
- Set {_sin} to {sin.value}
- Execute console command "/cos %number-argument%"
- Set {_cos} to {cos.value}
- Set {_t} to {_sin} / {_cos}
- Set {tan.value} to {_t}
- If {@message} is "true":
- Send "%{tan.value}%" to player
- #Calculate the arcsine of a sine of a degree
- Command /arcsin <number>:
- Permission: {@permission}
- Usage: /arcsin <sin(degree)>
- Trigger:
- Set {_x} to number-argument
- If {_x} is smaller than -1:
- Send "The value has to be bigger/equal to -1" to player
- If {_x} is bigger than 1:
- Send "The value has to be smaller/equal to 1" to player
- Execute console command "/arccos %{_x}%"
- Set {_ac} to {arccos.value}
- Set {_ac} to {_ac} * 2 * {@pi} / 360
- Set {_as} to ({@pi} / 2 - {_ac}) * 360 / (2 * {@pi})
- Set {arcsin.value} to {_as}
- If {@message} is "true":
- Send "%{arcsin.value}%" to player
- #Calculate the arccosine of a cosine of a degree
- Command /arccos <number>:
- Permission: {@permission}
- Usage: /arccos <cos(degree)>
- Trigger:
- Set {_x} to number-argument
- If {_x} is smaller than -1:
- Send "The value has to be bigger/equal to -1" to player
- If {_x} is bigger than 1:
- Send "The value has to be smaller/equal to 1" to player
- Set {_ac} to ((-0.69813170079773212 * {_x} * {_x} - 0.87266462599716477) * {_x} + 1.5707963267948966) * 360 / (2 * {@pi})
- Set {arccos.value} to {_ac}
- IF {@message} is "true":
- Send "%{arccos.value}%" to player
- #Calculate the arctangent of a tangent of a degree
- Command /arctan <number>:
- Permission: {@permission}
- Usage: /arctan <tan(degree)>
- Trigger:
- Set {_x} to number-argument
- If {_x} is smaller than -1:
- Send "The value has to be bigger/equal to -1" to player
- stop
- If {_x} is bigger than 1:
- Send "The value has to be smaller/equal to 1" to player
- stop
- Set {_absx} to ({_x} ^ 2) ^ 0.5
- Set {_at} to ({@pi} / 4 * {_x} - ({_absx} - 1) * (0.2447 + 0.0663 * {_absx})) * 360 / (2 * {@pi})
- Set {arctan.value} to {_at}
- If {@message} is "true":
- Send "%{arctan.value}%" to player
- #Calculate a rotation
- Command /rotate <number> <number>:
- Permission: {@permission}
- Trigger:
- Set {_Radius} to argument 1
- Set {_Angle} to argument 2
- Set {_Number} to floor( 360 / {_Angle} )
- Loop {_Number} times:
- If {_Current} is not set:
- Set {_Current} to 0
- Else:
- Add {_Angle} to {_Current}
- Set {_x} to ( {_Current} / 180 ) * 3.14159265358979323846
- Set {_c} to 1
- Loop 10 times:
- Set {_n} to loop-number-2 * 2
- Set {_f} to {_n}
- Set {_i} to {_f} - 1
- Loop {_i} times:
- Set {_f} to {_f} * {_i}
- Subtract 1 from {_i}
- Set {_c} to {_c} + (({_x} ^ {_n}) / {_f}) * (-1 ^ loop-number-2)
- Set {_c} to ( {_c} * {_Radius})
- Set {_s} to {_x}
- Loop 10 times:
- Set {_n} to loop-number-2 * 2 + 1
- Set {_f} to {_n}
- Set {_i} to {_f} - 1
- Loop {_i} times:
- Set {_f} to {_f} * {_i}
- Subtract 1 from {_i}
- Set {_s} to {_s} + (({_x} ^ {_n}) / {_f}) * (-1 ^ loop-number-2)
- Set {_s} to ( {_s} * {_Radius})
- Set {_Particlespawn} to location of player
- Increase x-coordinate of {_Particlespawn} by {_c}
- Increase Z-coordinate of {_Particlespawn} by {_s}
- Set {rotate.value} to {_Particlespawn}
- If {@message} is "true":
- Broadcast "%{_Particlespawn}%"
Advertisement
Add Comment
Please, Sign In to add comment