biosphere2/scripts/gallery.sk
2017-11-26 01:22:42 +01:00

122 lines
3.9 KiB
Plaintext

function hsvtorgb(col: text, h: number, sat: number, val: number) :: number:
set {_h} to mod({_h}, 360)
if {_sat} > 1:
set {_sat} to 1
else if {_sat} < 0:
set {_sat} to 0
if {_val} > 1:
set {_val} to 1
else if {_val} < 0:
set {_val} to 0
set {_c} to {_val} * {_sat}
set {_hh} to {_h}/60
set {_t} to mod({_hh}, 2) - 1
set {_x} to {_c} * (1 - abs({_t}))
set {_m} to {_v} - {_c}
set {_ret} to {_m}
if {_col} is "red" or "r":
if {_hh} < 1:
add {_c} to {_ret}
else if {_hh} < 2:
add {_x} to {_ret}
else if {_hh} < 4:
set {_ret} to {_ret}
else if {_hh} < 5:
add {_x} to {_ret}
else if {_hh} < 6:
add {_c} to {_ret}
else if {_col} is "green" or "g":
if {_hh} < 1:
add {_x} to {_ret}
else if {_hh} < 2:
add {_c} to {_ret}
else if {_hh} < 3:
add {_c} to {_ret}
else if {_hh} < 4:
add {_x} to {_ret}
else if {_col} is "blue" or "b":
if {_hh} < 2:
set {_ret} to {_ret}
else if {_hh} < 3:
add {_x} to {_ret}
else if {_hh} < 5:
add {_c} to {_ret}
else if {_hh} < 6:
add {_x} to {_ret}
return 0-{_ret}
function rgb(r: number, g: number, b: number, locs: locations):
loop {_locs::*}:
set {_x} to x-coordinate of loop-value
set {_y} to y-coordinate of loop-value
set {_z} to z-coordinate of loop-value
execute command "/particle reddust %{_x}% %{_y}% %{_z}% %{_r}% %{_g}% %{_b}% 1"
function rainbow(h: number, locs: locations):
set {_r} to hsvtorgb("r", {_h}, 1, 1)
set {_g} to hsvtorgb("g", {_h}, 1, 1)
set {_b} to hsvtorgb("b", {_h}, 1, 1)
rgb({_r}, {_g}, {_b}, {_locs::*})
command /rainbow-halo:
trigger:
set {_circle::*} to circle with radius 0.75 and density 5
set {_hue} to 0
set {run} to true
while {run} is true:
loop {_circle::*}:
set {_loc} to location 2 above player offset by loop-value in frame of player
rainbow({_hue}, {_loc})
add 5 to {_hue}
if {_hue} > 360:
set {_hue} to {_hue} - 360
if {run} is true:
wait 2 ticks
else:
stop trigger
command /rainbow-yaw-helix:
trigger:
set {_helix::*} to helix with radius 1, height 2, step 0.25 and density 10
set {_hue} to 0
set {run} to true
while {run} is true:
loop {_helix::*}:
set {_loc} to player offset by loop-value
set {_yaw} to yaw of player
rainbow({_yaw}, {_loc})
if {run} is true:
wait 1 tick
else:
stop trigger
function rainbow_lines(p: player):
set {_yaw} to random number from 0 to 360
set {_startheight} to random number from -0.5 to 1.5
set {_endheight} to {_startheight} + random number from 1 to 2
set {_hue} to random number from 0 to 360
set {_start} to cylindrical vector with radius 0.75, yaw {_yaw} and height {_startheight}
set {_end} to cylindrical vector with radius 0.75, yaw {_yaw} and height {_endheight}
set {_line::*} to vector line from {_start} to {_end} with density 5
loop {_line::*}:
set {_loc} to {_p} offset by loop-value
rainbow({_hue}, {_loc})
if {run} is true:
wait 1 tick
else:
stop loop
command /rainbow-lines:
trigger:
set {_line::*} to vector line from vector 0, 0, 0 to vector 0, 1, 0 with density 5
set {_size} to size of {_line::*}
set {run} to true
while {run} is true:
chance of 50%:
rainbow_lines(player)
wait 5 ticks
command /stopeffect:
trigger:
clear {run}