mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-22 03:27:05 +01:00
Merge branch 'master' of github.com:Baystation12/Baystation12
This commit is contained in:
@@ -557,10 +557,6 @@ proc/process_ghost_teleport_locs()
|
||||
name = "Escape Shuttle Hallway"
|
||||
icon_state = "escape"
|
||||
|
||||
/area/hallway/secondary/construction
|
||||
name = "Construction Area"
|
||||
icon_state = "construction"
|
||||
|
||||
/area/hallway/secondary/entry
|
||||
name = "Arrival Shuttle Hallway"
|
||||
icon_state = "entry"
|
||||
@@ -585,16 +581,24 @@ proc/process_ghost_teleport_locs()
|
||||
name = "Courtroom"
|
||||
icon_state = "courtroom"
|
||||
|
||||
/area/crew_quarters/heads
|
||||
/area/crew_quarters/heads/hop
|
||||
name = "Head of Personnel's Quarters"
|
||||
icon_state = "head_quarters"
|
||||
|
||||
/area/crew_quarters/hor
|
||||
name = "Research Director's Office"
|
||||
/area/crew_quarters/heads/hor
|
||||
name = "Research Director's Quarters"
|
||||
icon_state = "head_quarters"
|
||||
|
||||
/area/crew_quarters/chief
|
||||
name = "Chief Engineer's Office"
|
||||
/area/crew_quarters/heads/ce
|
||||
name = "Chief Engineer's Quarters"
|
||||
icon_state = "head_quarters"
|
||||
|
||||
/area/crew_quarters/heads/hos
|
||||
name = "Head of Security's Quarters"
|
||||
icon_state = "head_quarters"
|
||||
|
||||
/area/crew_quarters/heads/cmo
|
||||
name = "Chief Medical Officer's Quarters"
|
||||
icon_state = "head_quarters"
|
||||
|
||||
/area/mint
|
||||
@@ -982,6 +986,10 @@ proc/process_ghost_teleport_locs()
|
||||
name = "Research Lab"
|
||||
icon_state = "researchlab"
|
||||
|
||||
/area/toxins/rdoffice
|
||||
name = "Research Director's Office"
|
||||
icon_state = "head_quarters"
|
||||
|
||||
/area/toxins/xenobiology
|
||||
name = "Xenobiology Lab"
|
||||
icon_state = "xenolab"
|
||||
@@ -1157,6 +1165,14 @@ proc/process_ghost_teleport_locs()
|
||||
name = "Construction Area"
|
||||
icon_state = "yellow"
|
||||
|
||||
/area/construction/under_construction_small
|
||||
name = "Construction Area"
|
||||
icon_state = "construction"
|
||||
|
||||
/area/construction/under_construction_large
|
||||
name = "Construction Area"
|
||||
icon_state = "construction"
|
||||
|
||||
/area/construction/supplyshuttle
|
||||
name = "Supply Shuttle"
|
||||
icon_state = "yellow"
|
||||
|
||||
@@ -41,6 +41,9 @@
|
||||
var/obj/screen/healths = null
|
||||
var/obj/screen/throw_icon = null
|
||||
var/obj/screen/nutrition_icon = null
|
||||
var/obj/screen/gun/item/item_use_icon = null
|
||||
var/obj/screen/gun/move/gun_move_icon = null
|
||||
var/obj/screen/gun/run/gun_run_icon = null
|
||||
|
||||
var/total_luminosity = 0 //This controls luminosity for mobs, when you pick up lights and such this is edited. If you want the mob to use lights it must update its lum in its life proc or such. Note clamp this value around 7 or such to prevent massive light lag.
|
||||
var/last_luminosity = 0
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
/* Atom procs
|
||||
These procs expand on the basic built in procs.
|
||||
|
||||
Bumped(O)
|
||||
Automatically called whenever a movable atom O Bump()s into src.
|
||||
Proc protype designed to be overridden for specific objects.
|
||||
|
||||
Trigger(O)
|
||||
Automatically called whenever a movable atom O steps into the same
|
||||
turf with src.
|
||||
Proc protype designed to be overridden for specific objects.
|
||||
*/
|
||||
|
||||
atom
|
||||
proc
|
||||
Bumped(O)
|
||||
// O just Bump()ed into src.
|
||||
// prototype Bumped() proc for all atoms
|
||||
Trigger(O)
|
||||
|
||||
atom/movable
|
||||
|
||||
Bump(atom/A)
|
||||
if(istype(A)) A.Bumped(src) // tell A that src bumped into it
|
||||
..()
|
||||
|
||||
turf
|
||||
Entered(atom/O)
|
||||
for(var/atom/A in contents - O)
|
||||
if(O)
|
||||
O.Trigger(A)
|
||||
..()
|
||||
@@ -0,0 +1,131 @@
|
||||
/* base 64 procs
|
||||
These procs convert plain text to a hexidecimal string to 64 encoded text and vice versa.
|
||||
|
||||
sd_base64toHex(encode64, pad_code = 67)
|
||||
Accepts a base 64 encoded text and returns the hexidecimal equivalent.
|
||||
ARGS:
|
||||
encode64 = the base64 text to convert
|
||||
pad_code = the character or ASCII code used to pad the base64 text.
|
||||
DEFAULT: 67 (= sign)
|
||||
RETURNS: the hexidecimal text
|
||||
|
||||
sd_hex2base64(hextext, pad_char = "=")
|
||||
Accepts a hexidecimal string and returns the base 64 encoded text equivalent.
|
||||
ARGS:
|
||||
hextext = hex text to convert
|
||||
pad_char = the character or ASCII code used to pad the base64 text.
|
||||
DEFAULT: "=" (ASCII 67)
|
||||
RETURNS: the base64 text
|
||||
|
||||
sd_hex2text(hex)
|
||||
Accepts a hexidecimal string and returns the plain text equivalent.
|
||||
|
||||
sd_text2hex(txt)
|
||||
Accepts a plain text string and returns the hexidecimal equivalent.
|
||||
*/
|
||||
|
||||
/*********************************************
|
||||
* Implimentation: No need to read further. *
|
||||
*********************************************/
|
||||
proc
|
||||
sd_base64toHex(encode64, pad_code = 67)
|
||||
/* convert the base 64 text encode64 to hexidecimal text
|
||||
pad_code = the character or ASCII code used to pad the base64 text.
|
||||
DEFAULT: 67 (= sign)
|
||||
RETURNS: the hexidecimal text */
|
||||
var
|
||||
pos = 1
|
||||
offset = 2
|
||||
current = 0
|
||||
padding = 0
|
||||
hextext = ""
|
||||
if(istext(pad_code)) pad_code = text2ascii(pad_code)
|
||||
while(pos <= length(encode64))
|
||||
var/val = text2ascii(encode64, pos++)
|
||||
if((val >= 65) && (val <= 90)) // A to Z
|
||||
val -= 65
|
||||
else if((val >= 97) && (val <= 122)) // a to z
|
||||
val -= 71
|
||||
else if((val >= 48) && (val <= 57)) // 0 to 9
|
||||
val += 4
|
||||
else if(val == 43) // + sign
|
||||
val = 62
|
||||
else if(val == 47) // / symbol
|
||||
val = 63
|
||||
else if(pad_code) // padding
|
||||
// the = sign indicates that some 0 bits were appended to pad the original string to
|
||||
val = -1
|
||||
padding ++
|
||||
else // anything else (presumably whitespace)
|
||||
val = -1
|
||||
if(val < 0) continue // whitespace and padding ignored
|
||||
|
||||
if(offset>2)
|
||||
var/lft = val >> (8 - offset)
|
||||
current |= lft
|
||||
hextext += sd_dec2base(current,,2)
|
||||
|
||||
current = (val << offset) & 0xFF
|
||||
|
||||
offset += 2
|
||||
if(offset > 8)
|
||||
offset = 2
|
||||
|
||||
if(padding)
|
||||
hextext = copytext(hextext, 1, length(hextext) + 1 - padding * 2)
|
||||
return hextext
|
||||
|
||||
sd_hex2base64(hextext, pad_char = "=")
|
||||
/* convert the hexidecimal string hextext to base 64 encoded text
|
||||
pad_char = the character or ASCII code used to pad the base64 text.
|
||||
DEFAULT: "=" (ASCII 67)
|
||||
RETURNS: the base 64 encoded text */
|
||||
var
|
||||
key64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
|
||||
encode64 = ""
|
||||
pos = 1
|
||||
offset = 2
|
||||
current = 0
|
||||
len = length(hextext)
|
||||
end = len
|
||||
padding = end%6
|
||||
if(padding)
|
||||
padding = 6 - padding
|
||||
end += padding
|
||||
padding >>= 1
|
||||
if(isnum(pad_char)) pad_char = ascii2text(pad_char)
|
||||
while(pos <= end)
|
||||
var/val = 0 // pad with 0s
|
||||
if(pos < len) val = sd_base2dec(copytext(hextext, pos, pos+2))
|
||||
pos+=2
|
||||
|
||||
var/lft = val >> offset
|
||||
current |= lft
|
||||
encode64 += copytext(key64,current+1,current+2)
|
||||
|
||||
current = (val << (6-offset)) & 0x3F
|
||||
|
||||
offset += 2
|
||||
if(offset>6)
|
||||
encode64 += copytext(key64,current+1,current+2)
|
||||
offset = 2
|
||||
current = 0
|
||||
for(var/x = 1 to padding)
|
||||
encode64 += pad_char
|
||||
return encode64
|
||||
|
||||
sd_hex2text(hex)
|
||||
/* convert hexidecimal text to a plain text string
|
||||
RETURNS: the plain text */
|
||||
var/txt = ""
|
||||
for(var/loop = 1 to length(hex) step 2)
|
||||
txt += ascii2text(sd_base2dec(copytext(hex,loop, loop+2)))
|
||||
return txt
|
||||
|
||||
sd_text2hex(txt)
|
||||
/* convert plain text to a hexidecimal string
|
||||
RETURNS: the hexidecimal text */
|
||||
var/hex = ""
|
||||
for(var/loop = 1 to length(txt))
|
||||
hex += sd_dec2base(text2ascii(txt,loop),,2)
|
||||
return hex
|
||||
@@ -0,0 +1,75 @@
|
||||
/* sd_color and procs
|
||||
sd_color is a special datum that contains color data in various
|
||||
formats. Sample colors are available in samplecolors.dm.
|
||||
|
||||
sd_color
|
||||
var
|
||||
name // the name of the color
|
||||
red // red componant of the color
|
||||
green // green componant of the color
|
||||
blue // red componant of the color
|
||||
html // html string for the color
|
||||
icon/Icon // contains the icon produced by the rgb2icon() proc
|
||||
|
||||
PROCS
|
||||
brightness()
|
||||
Returns the grayscale brightness of the RGB color set.
|
||||
|
||||
html2rgb()
|
||||
Calculates the rgb colors from the html colors.
|
||||
|
||||
rgb2html()
|
||||
Calculates the html color from the rbg colors.
|
||||
|
||||
rgb2icon()
|
||||
Converts the rgb value to a solid icon stored as src.Icon
|
||||
|
||||
*/
|
||||
|
||||
/*********************************************
|
||||
* Implimentation: No need to read further. *
|
||||
*********************************************/
|
||||
sd_color
|
||||
var
|
||||
name // the name of the color
|
||||
red = 0 // red componant of the color
|
||||
green = 0 // green componant of the color
|
||||
blue = 0 // red componant of the color
|
||||
html // html string for the color
|
||||
icon/Icon // contains the icon produced by the rgb2icon() proc
|
||||
|
||||
proc
|
||||
brightness()
|
||||
/* returns the grayscale brightness of the RGB colors. */
|
||||
return round((red*30 + green*59 + blue*11)/100,1)
|
||||
|
||||
html2rgb()
|
||||
/* Calculates the rgb colors from the html colors */
|
||||
red = sd_base2dec(copytext(html,1,3))
|
||||
green = sd_base2dec(copytext(html,3,5))
|
||||
blue = sd_base2dec(copytext(html,5,7))
|
||||
|
||||
rgb2html()
|
||||
/* Calculates the html color from the rbg colors */
|
||||
html = sd_dec2base(red,,2) + sd_dec2base(green,,2) + sd_dec2base(blue,,2)
|
||||
return html
|
||||
|
||||
rgb2icon()
|
||||
/* Converts the rgb value to a solid icon stored as src.Icon */
|
||||
Icon = 'Black.dmi' + rgb(red,green,blue)
|
||||
return Icon
|
||||
|
||||
New()
|
||||
..()
|
||||
// if this is an unnamed subtype, name it according to it's type
|
||||
if(!name)
|
||||
name = "[type]"
|
||||
var/slash = sd_findlast(name,"/")
|
||||
if(slash)
|
||||
name = copytext(name,slash+1)
|
||||
name = sd_replacetext(name,"_"," ")
|
||||
|
||||
if(html) // if there is an html string
|
||||
html2rgb() // convert the html to red, green, & blue values
|
||||
else
|
||||
rgb2html() // convert the red, green, & blue values to html
|
||||
@@ -0,0 +1 @@
|
||||
#define PI 3.141592654
|
||||
@@ -0,0 +1,154 @@
|
||||
/* Direction procs
|
||||
These procs deal with BYOND directions.
|
||||
|
||||
sd_get_approx_dir(atom/ref,atom/target)
|
||||
returns the approximate direction from ref to target.
|
||||
|
||||
sd_degrees2dir(degrees as num)
|
||||
Accepts an angle in degrees and returns the closest BYOND
|
||||
direction value.
|
||||
|
||||
sd_dir2degrees(dir as num)
|
||||
Accepts a BYOND direction value and returns the angle North of
|
||||
East in degrees.
|
||||
|
||||
sd_dir2radial(dir as num)
|
||||
Accepts a BYOND direction value and returns the radial direction
|
||||
(0-7) North of East.
|
||||
|
||||
sd_dir2radians(dir as num)
|
||||
Accepts a BYOND direction value and returns the angle North of
|
||||
East in radians.
|
||||
|
||||
sd_dir2text(dir as num)
|
||||
Accepts a BYOND direction value and returns the lowercase text
|
||||
name of the direction.
|
||||
|
||||
sd_dir2Text(dir as num)
|
||||
Accepts a BYOND direction value and returns the Capitalized text
|
||||
name of the direction
|
||||
|
||||
sd_radial2dir(radial as num)
|
||||
Accepts a radial direction (0-7) and returns the BYOND direction
|
||||
value.
|
||||
*/
|
||||
|
||||
/*********************************************
|
||||
* Implimentation: No need to read further. *
|
||||
*********************************************/
|
||||
proc
|
||||
sd_get_approx_dir(atom/ref,atom/target)
|
||||
/* returns the approximate direction from ref to target.
|
||||
Code by Lummox JR
|
||||
http://www.byond.com/forum/forum.cgi?action=message_list&query=Post+ID%3A153964#153964
|
||||
*/
|
||||
var/d=get_dir(ref,target)
|
||||
if(d&d-1) // diagonal
|
||||
var/ax=abs(ref.x-target.x)
|
||||
var/ay=abs(ref.y-target.y)
|
||||
if(ax>=ay<<1) return d&12 // keep east/west (4 and 8)
|
||||
else if(ay>=ax<<1) return d&3 // keep north/south (1 and 2)
|
||||
return d
|
||||
|
||||
sd_degrees2dir(degrees as num)
|
||||
/* accepts an angle in degrees and returns the closest BYOND
|
||||
direction value */
|
||||
var/error_report = degrees // for error tracking
|
||||
|
||||
// force angle into a range between 0 and 360
|
||||
degrees %= 360
|
||||
if(degrees < 0)
|
||||
degrees += 360
|
||||
|
||||
// BYOND dirs are at 45 degree angles
|
||||
degrees = round(degrees,45)
|
||||
|
||||
switch(degrees)
|
||||
if(0,360) return EAST
|
||||
if(45) return NORTHEAST
|
||||
if(90) return NORTH
|
||||
if(135) return NORTHWEST
|
||||
if(180) return WEST
|
||||
if(225) return SOUTHWEST
|
||||
if(270) return SOUTH
|
||||
if(315) return SOUTHEAST
|
||||
else
|
||||
world.log << "Error in sd_degrees2dir(): [error_report] -> [degrees]"
|
||||
|
||||
sd_dir2degrees(dir as num)
|
||||
/* accepts a BYOND direction value and returns the angle North of
|
||||
East in degrees */
|
||||
switch(dir)
|
||||
if(EAST) return 0
|
||||
if(NORTHEAST) return 45
|
||||
if(NORTH) return 90
|
||||
if(NORTHWEST) return 135
|
||||
if(WEST) return 180
|
||||
if(SOUTHWEST) return 225
|
||||
if(SOUTH) return 270
|
||||
if(SOUTHEAST) return 315
|
||||
|
||||
sd_dir2radial(dir as num)
|
||||
/* accepts a BYOND direction value and returns the radial direction
|
||||
(0-7) North of East */
|
||||
switch(dir)
|
||||
if(EAST) return 0
|
||||
if(NORTHEAST) return 1
|
||||
if(NORTH) return 2
|
||||
if(NORTHWEST) return 3
|
||||
if(WEST) return 4
|
||||
if(SOUTHWEST) return 5
|
||||
if(SOUTH) return 6
|
||||
if(SOUTHEAST) return 7
|
||||
|
||||
sd_dir2radians(dir as num)
|
||||
/* accepts a BYOND direction value and returns the angle North of
|
||||
East in radians */
|
||||
switch(dir)
|
||||
if(EAST) return 0
|
||||
if(NORTHEAST) return PI/4
|
||||
if(NORTH) return PI/2
|
||||
if(NORTHWEST) return PI*3/4
|
||||
if(WEST) return PI
|
||||
if(SOUTHWEST) return PI*5/4
|
||||
if(SOUTH) return PI*3/2
|
||||
if(SOUTHEAST) return PI*7/4
|
||||
|
||||
sd_dir2text(dir as num)
|
||||
/* accepts a direction and returns the lowercase text name of
|
||||
the direction */
|
||||
switch(dir)
|
||||
if(NORTH) return "north"
|
||||
if(SOUTH) return "south"
|
||||
if(EAST) return "east"
|
||||
if(WEST) return "west"
|
||||
if(NORTHEAST) return "northeast"
|
||||
if(SOUTHEAST) return "southeast"
|
||||
if(NORTHWEST) return "northwest"
|
||||
if(SOUTHWEST) return "southwest"
|
||||
|
||||
sd_dir2Text(dir as num)
|
||||
/* accepts a direction and returns the Capitalized text name of
|
||||
the direction */
|
||||
switch(dir)
|
||||
if(NORTH) return "North"
|
||||
if(SOUTH) return "South"
|
||||
if(EAST) return "East"
|
||||
if(WEST) return "West"
|
||||
if(NORTHEAST) return "Northeast"
|
||||
if(SOUTHEAST) return "Southeast"
|
||||
if(NORTHWEST) return "Northwest"
|
||||
if(SOUTHWEST) return "Southwest"
|
||||
|
||||
sd_radial2dir(radial as num)
|
||||
/* accepts a radial direction (0-7) and returns the BYOND direction
|
||||
value */
|
||||
switch(radial)
|
||||
if(0) return EAST
|
||||
if(1) return NORTHEAST
|
||||
if(2) return NORTH
|
||||
if(3) return NORTHWEST
|
||||
if(4) return WEST
|
||||
if(5) return SOUTHWEST
|
||||
if(6) return SOUTH
|
||||
if(7) return SOUTHEAST
|
||||
@@ -0,0 +1,186 @@
|
||||
/* HSL procs
|
||||
These procs convert between RGB (red, green, blu) and HSL (hue, saturation, light)
|
||||
color spaces. The algorithms used for these procs were found at
|
||||
http://www.paris-pc-gis.com/MI_Enviro/Colors/color_models.htm
|
||||
|
||||
hsl2rgb(hue, sat, lgh, scale = 240)
|
||||
Returns the RRGGBB format of an HSL color.
|
||||
|
||||
ALTERNATE FORMAT:
|
||||
hsl2rgb(HSL, scale)
|
||||
ARGS:
|
||||
hue - hue
|
||||
sat - saturation
|
||||
lgh - light/dark
|
||||
HSL - a hex string in format HHSSLL where:
|
||||
HH = Hue from
|
||||
SS = Saturation
|
||||
LL = light
|
||||
scale - high end of the HSL values. Some programs (like BYOND Dream Maker)
|
||||
use 240, others use 255. The H {0-360}, S {0-100}, L {0-100}
|
||||
scale is not supported.
|
||||
DEFAULT: 240
|
||||
RETURNS:
|
||||
RGB color string in RRGGBB format.
|
||||
|
||||
rgb2hsl(red, grn, blu, scale = 240)
|
||||
Returns the HSL color string of an RGB color
|
||||
|
||||
ALTERNATE FORMAT:
|
||||
rgb2hsl(RGB, scale)
|
||||
ARGS:
|
||||
red - red componant {0-255}
|
||||
grn - green componant {0-255}
|
||||
blu - blue componant {0-255}
|
||||
RGB - a hex string in format RRGGBB
|
||||
scale - high end of the HSL values. Some programs (like BYOND Dream Maker)
|
||||
use 240, others use 255. The H {0-360}, S {0-100}, L {0-100}
|
||||
scale is not supported.
|
||||
DEFAULT: 240
|
||||
RETURNS:
|
||||
HHSSLL color string
|
||||
*/
|
||||
|
||||
/*********************************************
|
||||
* Implimentation: No need to read further. *
|
||||
*********************************************/
|
||||
|
||||
proc
|
||||
hsl2rgb(hue, sat, lgh, scale = 240)
|
||||
/* Returns the RRGGBB format of an HSL color string
|
||||
algorithm from http://www.paris-pc-gis.com/MI_Enviro/Colors/color_models.htm
|
||||
ALTERNATE FORMAT:
|
||||
hsl2rgb(HSL, scale)
|
||||
ARGS:
|
||||
hue - hue
|
||||
sat - saturation
|
||||
lgh - light/dark
|
||||
HSL - a hex string in format HHSSLL where:
|
||||
HH = Hue from
|
||||
SS = Saturation
|
||||
LL = light
|
||||
scale - high end of the HSL values. Some programs (like BYOND Dream Maker)
|
||||
use 240, others use 255. The H {0-360}, S {0-100}, L {0-100}
|
||||
scale is not supported.
|
||||
DEFAULT: 240
|
||||
RETURNS:
|
||||
RGB color string in RRGGBB format. */
|
||||
|
||||
if(istext(hue)) // used alternate hsl2rgb("HHSSLL", scale)
|
||||
if(length(hue)!=6)
|
||||
CRASH("hsl2rbg('[hue]'): text argument must be a 6 character hex code.")
|
||||
return
|
||||
if(isnum(sat)) scale = sat
|
||||
lgh = sd_base2dec(copytext(hue,5))
|
||||
sat = sd_base2dec(copytext(hue,3,5))
|
||||
hue = sd_base2dec(copytext(hue,1,3))
|
||||
|
||||
// scale decimal {0-1}
|
||||
hue /= scale
|
||||
sat /= scale
|
||||
lgh /= scale
|
||||
|
||||
var
|
||||
red
|
||||
grn
|
||||
blu
|
||||
|
||||
if(!sat) // greyscale
|
||||
red = lgh
|
||||
grn = lgh
|
||||
blu = lgh
|
||||
else
|
||||
var
|
||||
temp1
|
||||
temp2
|
||||
temp3
|
||||
if(lgh < 0.5) temp2 = lgh * (1 + sat)
|
||||
else temp2 = lgh + sat - lgh * sat
|
||||
temp1 = 2 * lgh - temp2
|
||||
|
||||
// red
|
||||
temp3 = hue + 1/3
|
||||
if(temp3 > 1) temp3--
|
||||
if(6*temp3<1) red = temp1 + (temp2 - temp1) * 6 * temp3
|
||||
else if(2*temp3<1) red = temp2
|
||||
else if(3*temp3<2) red = temp1 + (temp2 - temp1) * ((2/3) - temp3) * 6
|
||||
else red = temp1
|
||||
|
||||
// green
|
||||
temp3 = hue
|
||||
if(6*temp3<1) grn = temp1 + (temp2 - temp1) * 6 * temp3
|
||||
else if(2*temp3<1) grn = temp2
|
||||
else if(3*temp3<2) grn = temp1 + (temp2 - temp1) * ((2/3) - temp3) * 6
|
||||
else grn = temp1
|
||||
|
||||
// blue
|
||||
temp3 = hue - 1/3
|
||||
if(temp3 < 0) temp3++
|
||||
if(6*temp3<1) blu = temp1 + (temp2 - temp1) * 6 * temp3
|
||||
else if(2*temp3<1) blu = temp2
|
||||
else if(3*temp3<2) blu = temp1 + (temp2 - temp1) * ((2/3) - temp3) * 6
|
||||
else blu = temp1
|
||||
|
||||
// shift from {0-1} scale to integers {0-255}
|
||||
red = round(red*255, 1)
|
||||
grn = round(grn*255, 1)
|
||||
blu = round(blu*255, 1)
|
||||
|
||||
// return 6 digit hex string
|
||||
return sd_dec2base(red,16, 2) + sd_dec2base(grn,16, 2) + sd_dec2base(blu,16, 2)
|
||||
|
||||
|
||||
rgb2hsl(red, grn, blu, scale = 240)
|
||||
/* Returns the HSL color string of a RGB color
|
||||
algorithm from http://www.paris-pc-gis.com/MI_Enviro/Colors/color_models.htm
|
||||
ALTERNATE FORMAT:
|
||||
rgb2hsl(RGB, scale)
|
||||
ARGS:
|
||||
red - red componant {0-255}
|
||||
grn - green componant {0-255}
|
||||
blu - blue componant {0-255}
|
||||
RGB - a hex string in format RRGGBB
|
||||
scale - high end of the HSL values. Some programs (like BYOND Dream Maker)
|
||||
use 240, others use 255. The H {0-360}, S {0-100}, L {0-100}
|
||||
scale is not supported.
|
||||
DEFAULT: 240
|
||||
RETURNS:
|
||||
HHSSLL color string */
|
||||
|
||||
if(istext(red)) // used alternate rgb2hsl("RRGGBB", scale) format
|
||||
if(length(red)!=6)
|
||||
CRASH("rbg2hsl('[red]'): text argument must be a 6 character hex code.")
|
||||
return
|
||||
if(isnum(grn)) scale = grn
|
||||
blu = sd_base2dec(copytext(red,5))
|
||||
grn = sd_base2dec(copytext(red,3,5))
|
||||
red = sd_base2dec(copytext(red,1,3))
|
||||
|
||||
// scale decimal {0-1}
|
||||
red /= 255
|
||||
grn /= 255
|
||||
blu /= 255
|
||||
var
|
||||
lo = min(red, grn, blu)
|
||||
hi = max(red, grn, blu)
|
||||
hue = 0
|
||||
sat = 0
|
||||
lgh = (lo + hi)/2
|
||||
|
||||
if(lo != hi) // if equal, hue and sat may both stay 0
|
||||
if(lgh < 0.5) sat = (hi - lo) / (hi + lo)
|
||||
else sat = (hi - lo) / (2 - hi - lo)
|
||||
// produce hue as value from 0-6
|
||||
if(red == hi) hue = (grn - blu) / (hi - lo)
|
||||
else if(grn == hi) hue = 2 + (blu - red) / (hi - lo)
|
||||
else hue = 4 + (red - grn) / (hi - lo)
|
||||
if(hue<0) hue += 6
|
||||
|
||||
// convert decimal {0-1} to integer {0-scale}
|
||||
lgh = round(lgh * scale, 1)
|
||||
sat = round(sat * scale, 1)
|
||||
// convert hue as decimal 0-6 to integer {0-scale}
|
||||
hue = round((hue / 6) * scale, 1)
|
||||
|
||||
// return 6 digit hex string
|
||||
return sd_dec2base(hue,16, 2) + sd_dec2base(sat,16, 2) + sd_dec2base(lgh,16, 2)
|
||||
@@ -0,0 +1,117 @@
|
||||
/* Math procs
|
||||
These procs contain basic math routines.
|
||||
|
||||
sd_base2dec(number as text, base = 16 as num)
|
||||
Accepts a number in any base (2 to 36) and returns the equivelent
|
||||
value in decimal.
|
||||
ARGS:
|
||||
number - number to convert as a text string
|
||||
base - number base
|
||||
RETURNS:
|
||||
decimal value of the number
|
||||
|
||||
sd_dec2base(decimal,base = 16 as num,digits = 0 as num)
|
||||
Accepts a decimal number and returns the equivelent value in the
|
||||
new base as a string.
|
||||
ARGS:
|
||||
decimal - number to convert
|
||||
base - new number base
|
||||
digits - if output is less than digits, it will add
|
||||
preceeding 0s to pad it out
|
||||
RETURNS:
|
||||
equivelent value in the new base as a string
|
||||
|
||||
sd_get_dist(atom/A, atom/B)
|
||||
Returns the mathematical 3D distance between two atoms.
|
||||
|
||||
sd_get_dist_squared(atom/A, atom/B)
|
||||
Returns the square of the mathematical 3D distance between two atoms. (More processor
|
||||
friendly than sd_get_dist() and useful for modelling realworld physics.)
|
||||
*/
|
||||
|
||||
/*********************************************
|
||||
* Implimentation: No need to read further. *
|
||||
*********************************************/
|
||||
proc
|
||||
sd_base2dec(number as text, base = 16 as num)
|
||||
/* Accepts a number in any base (2 to 36) and returns the equivelent
|
||||
value in decimal.
|
||||
ARGS:
|
||||
number - number to convert as a text string
|
||||
base - number base
|
||||
RETURNS:
|
||||
decimal value of the number
|
||||
*/
|
||||
if(!istext(number))
|
||||
world.log << "sd_base2dec: invalid number string- [number]"
|
||||
return null
|
||||
if(!isnum(base) || (base < 2) || (base > 36))
|
||||
world.log << "sd_base2dec: invalid base - [base]"
|
||||
return null
|
||||
|
||||
var/decimal = 0
|
||||
number = uppertext(number)
|
||||
|
||||
for(var/loop = 1, loop <= lentext(number))
|
||||
var/digit = copytext(number,loop,++loop)
|
||||
if((digit >= "0") && (digit <= "9"))
|
||||
decimal = decimal * base + text2num(digit)
|
||||
else if((digit >= "A") && (digit <= "Z"))
|
||||
decimal = decimal * base + (text2ascii(digit) - 55)
|
||||
else
|
||||
break // terminate when it encounters an invalid character
|
||||
|
||||
return decimal
|
||||
|
||||
|
||||
sd_dec2base(decimal,base = 16 as num,digits = 0 as num)
|
||||
/* Accepts a decimal number and returns the equivelent value in the
|
||||
new base as a string.
|
||||
ARGS:
|
||||
decimal - number to convert
|
||||
base - new number base
|
||||
digits - if output is less than digits, it will add
|
||||
preceeding 0s to pad it out
|
||||
RETURNS:
|
||||
equivelent value in the new base as a string
|
||||
*/
|
||||
if(istext(decimal)) decimal = text2num(decimal)
|
||||
decimal = round(decimal)
|
||||
if(!isnum(decimal) || (decimal < 0))
|
||||
world.log << "sd_dec2base: invalid decimal number - [decimal]"
|
||||
return null
|
||||
if(!isnum(base) || (base < 2) || (base > 36))
|
||||
world.log << "sd_dec2base: invalid base - [base]"
|
||||
return null
|
||||
|
||||
var/text = ""
|
||||
if(!decimal) text = "0"
|
||||
while(decimal)
|
||||
var/n = decimal%base
|
||||
if(n<10)
|
||||
text = num2text(n) + text
|
||||
else
|
||||
text = ascii2text(55+n) + text
|
||||
|
||||
decimal = (decimal - n)/base
|
||||
|
||||
while(lentext(text) < digits)
|
||||
text = "0" + text
|
||||
|
||||
return text
|
||||
|
||||
|
||||
sd_get_dist(atom/A, atom/B)
|
||||
/* Returns the mathematical 3D distance between two atoms. */
|
||||
var/X = (A.x - B.x)
|
||||
var/Y = (A.y - B.y)
|
||||
var/Z = (A.z - B.z)
|
||||
return sqrt(X * X + Y * Y + Z * Z)
|
||||
|
||||
sd_get_dist_squared(atom/A, atom/B)
|
||||
/* Returns the square of the mathematical 3D distance between two atoms. (More processor
|
||||
friendly than sd_get_dist() and useful for modelling realworld physics.) */
|
||||
var/X = (A.x - B.x)
|
||||
var/Y = (A.y - B.y)
|
||||
var/Z = (A.z - B.z)
|
||||
return X * X + Y * Y + Z * Z
|
||||
@@ -0,0 +1,140 @@
|
||||
/* Nybble Colors
|
||||
Nybble colors is used to compact RGB colors to "nybble" (4 bits, 1 hex
|
||||
digit, or decimal numbers 0 to 15.) Since BYOND allows up to 16 bits in
|
||||
bitwise mathematics, you could store up to 4 color values in a single
|
||||
number. (The project inspiring these procs stores a foreground nybble
|
||||
color, background nybble color, and 8 bit text character in each 16 bit
|
||||
number.)
|
||||
|
||||
The value of each bit is:
|
||||
Bit: 4 3 2 1
|
||||
Component: Intensity Red Green Blue
|
||||
|
||||
Nybble color values are:
|
||||
Dec Hex Bin Color
|
||||
0 0 0000 null color. See the note below.
|
||||
1 1 0001 dark blue (navy)
|
||||
2 2 0010 dark green
|
||||
3 3 0011 dark cyan
|
||||
4 4 0100 dark red
|
||||
5 5 0101 dark magenta
|
||||
6 6 0110 brown
|
||||
7 7 0111 grey
|
||||
8 8 1000 black
|
||||
9 9 1001 blue
|
||||
10 A 1010 green
|
||||
11 B 1011 cyan
|
||||
12 C 1100 red
|
||||
13 D 1101 magenta
|
||||
14 E 1110 yellow
|
||||
15 F 1111 white
|
||||
|
||||
Null color note: rgb2nybble() will return a value of 8 for black, so
|
||||
that you may use 0 value nybbles for special cases in your own code.
|
||||
For example, in the project that inspired these procs, color 0
|
||||
indicates the default background, which is a textured image.
|
||||
nybble2rgb() will convert values of 0 or 8 to "000000" (or "000" if
|
||||
you specify short rgb.)
|
||||
|
||||
PROCS
|
||||
sd_nybble2rgb(original, bit = 8, short = 0)
|
||||
Converts a nybble color to an RGB hex color string.
|
||||
ARGS:
|
||||
value - the number containing the nibble
|
||||
bit - the MSB (most significant bit) of the nybble. The
|
||||
default value of 8 uses the lowest 4 bits of original.
|
||||
DEFAULT: 8
|
||||
short - short RGB flag. If this is set, the proc returns a
|
||||
3 character RGB string. Otherwise it returns a 6
|
||||
character RGB string.
|
||||
DEFAULT: 0 (return 6 characters)
|
||||
RETURNS:
|
||||
A 3 or 6 character hexidecimal RGB color string.
|
||||
|
||||
sd_rgb2nybble(rgb, bit = 8)
|
||||
Converts an rgb color string to a nybble color.
|
||||
ARGS:
|
||||
rgb - The color string to be converted. This may be a 3 or 6
|
||||
character color code with or without a leading "#".
|
||||
Examples: "000", "000000", "#000", "#000000" all
|
||||
indicate black.
|
||||
bit - the MSB (most significant bit) of the nybble. You can
|
||||
use this to shift the position of your nybble within
|
||||
the return value. The default value of 8 uses the
|
||||
lowest 4 bits.
|
||||
DEFAULT: 8
|
||||
RETURNS:
|
||||
A nybble color value or null if the proc failed.
|
||||
*/
|
||||
|
||||
/*********************************************
|
||||
* Implimentation: No need to read further. *
|
||||
*********************************************/
|
||||
proc
|
||||
sd_nybble2rgb(original, bit = 8, short = 0)
|
||||
/* Converts a nybble color to an RGB hex color string.
|
||||
ARGS:
|
||||
value - the number containing the nibble
|
||||
bit - the MSB (most significant bit) of the nybble. The
|
||||
default value of 8 uses the lowest 4 bits of original.
|
||||
DEFAULT: 8
|
||||
short - short RGB flag. If this is set, the proc returns a
|
||||
3 character RGB string. Otherwise it returns a 6
|
||||
character RGB string.
|
||||
DEFAULT: 0 (return 6 characters)
|
||||
RETURNS:
|
||||
A 3 or 6 character hexidecimal RGB color string. */
|
||||
var {intensity = "9"; off = "0"}
|
||||
if(original & bit) intensity = "F"
|
||||
if(!short)
|
||||
intensity += intensity
|
||||
off = "00"
|
||||
. = ""
|
||||
for(var/loop = 1 to 3)
|
||||
bit >>= 1
|
||||
if(original & bit) . += intensity
|
||||
else . += off
|
||||
if(. == "990") . = "940"
|
||||
else if(. == "999900") . = "994400"
|
||||
if(intensity == "F" && . == "000000") . = "00FF99"
|
||||
|
||||
sd_rgb2nybble(rgb, bit = 8)
|
||||
/* Converts an rgb color string to a nybble color.
|
||||
ARGS:
|
||||
rgb - The color string to be converted. This may be a 3 or 6
|
||||
character color code with or without a leading "#".
|
||||
Examples: "000", "000000", "#000", "#000000" all
|
||||
indicate black.
|
||||
bit - the MSB (most significant bit) of the nybble. You can
|
||||
use this to shift the position of your nybble within
|
||||
the return value. The default value of 8 uses the
|
||||
lowest 4 bits.
|
||||
DEFAULT: 8
|
||||
RETURNS:
|
||||
A nybble color value or null if the proc failed. */
|
||||
if(!istext(rgb)) return
|
||||
if(text2ascii(rgb) == 35) // leading "#"
|
||||
rgb = copytext(rgb,2)
|
||||
var{char; cmp[3]; cmp_size; hi = 0; loop; pos = 1}
|
||||
switch(length(rgb))
|
||||
if(3) cmp_size = 1
|
||||
if(6) cmp_size = 2
|
||||
else return
|
||||
for(loop = 1 to 3)
|
||||
char = copytext(rgb, pos, pos+1)
|
||||
// char 0 to 3 => 0, 4 to 9 => 1, A to F => 2
|
||||
// cmp[loop] = round(sd_base2dec(char, 16) * 0.15, 1)
|
||||
// previous line takes over twice as long as switch() method below
|
||||
switch(char)
|
||||
if("0", "1", "2", "3") cmp[loop] = 0
|
||||
if("4", "5", "6", "7", "8", "9") cmp[loop] = 1
|
||||
else cmp[loop] = 2
|
||||
if(cmp[loop] > hi) hi = cmp[loop]
|
||||
pos += cmp_size
|
||||
switch(hi)
|
||||
if(0) return bit // color 8: black
|
||||
if(2) . = bit // high intensity
|
||||
else . = 0 // low intensity
|
||||
for(loop = 1 to 3)
|
||||
bit >>= 1
|
||||
if(cmp[loop] == hi) . |= bit
|
||||
@@ -0,0 +1,310 @@
|
||||
/* Sample sd_colors. This file will not automatically be included in your
|
||||
projects, since you may want to define them differently.
|
||||
|
||||
Colors can be defined by rgb values:
|
||||
sd_color/blue
|
||||
red = 0
|
||||
green = 0
|
||||
blue = 255
|
||||
|
||||
Colors can be defined by HTML values:
|
||||
sd_color/green
|
||||
html = "00FF00"
|
||||
|
||||
Colors can be defined by just overriding selective rgb values:
|
||||
sd_color/red
|
||||
red = 255
|
||||
magenta
|
||||
// still has red = 255, since it is a child of red
|
||||
blue = 255
|
||||
*/
|
||||
|
||||
/******************************************************
|
||||
* Here 142 colors you might like to use from *
|
||||
* http://www.w3schools.com/html/html_colornames.asp *
|
||||
******************************************************/
|
||||
sd_color
|
||||
AliceBlue
|
||||
html = "F0F8FF"
|
||||
AntiqueWhite
|
||||
html = "FAEBD7"
|
||||
Aqua
|
||||
html = "00FFFF"
|
||||
Aquamarine
|
||||
html = "7FFFD4"
|
||||
Azure
|
||||
html = "F0FFFF"
|
||||
Beige
|
||||
html = "F5F5DC"
|
||||
Bisque
|
||||
html = "FFE4C4"
|
||||
Black
|
||||
html = "000000"
|
||||
BlanchedAlmond
|
||||
html = "FFEBCD"
|
||||
Blue
|
||||
html = "0000FF"
|
||||
BlueViolet
|
||||
html = "8A2BE2"
|
||||
Brown
|
||||
html = "A52A2A"
|
||||
BurlyWood
|
||||
html = "DEB887"
|
||||
CadetBlue
|
||||
html = "5F9EA0"
|
||||
Chartreuse
|
||||
html = "7FFF00"
|
||||
Chocolate
|
||||
html = "D2691E"
|
||||
Coral
|
||||
html = "FF7F50"
|
||||
CornflowerBlue
|
||||
html = "6495ED"
|
||||
Cornsilk
|
||||
html = "FFF8DC"
|
||||
Crimson
|
||||
html = "DC143C"
|
||||
Cyan
|
||||
html = "00FFFF"
|
||||
DarkBlue
|
||||
html = "00008B"
|
||||
DarkCyan
|
||||
html = "008B8B"
|
||||
DarkGoldenRod
|
||||
html = "B8860B"
|
||||
DarkGray
|
||||
html = "A9A9A9"
|
||||
DarkGreen
|
||||
html = "006400"
|
||||
DarkKhaki
|
||||
html = "BDB76B"
|
||||
DarkMagenta
|
||||
html = "8B008B"
|
||||
DarkOliveGreen
|
||||
html = "556B2F"
|
||||
Darkorange
|
||||
html = "FF8C00"
|
||||
DarkOrchid
|
||||
html = "9932CC"
|
||||
DarkRed
|
||||
html = "8B0000"
|
||||
DarkSalmon
|
||||
html = "E9967A"
|
||||
DarkSeaGreen
|
||||
html = "8FBC8F"
|
||||
DarkSlateBlue
|
||||
html = "483D8B"
|
||||
DarkSlateGray
|
||||
html = "2F4F4F"
|
||||
DarkTurquoise
|
||||
html = "00CED1"
|
||||
DarkViolet
|
||||
html = "9400D3"
|
||||
DeepPink
|
||||
html = "FF1493"
|
||||
DeepSkyBlue
|
||||
html = "00BFFF"
|
||||
DimGray
|
||||
html = "696969"
|
||||
DodgerBlue
|
||||
html = "1E90FF"
|
||||
FireBrick
|
||||
html = "B22222"
|
||||
FloralWhite
|
||||
html = "FFFAF0"
|
||||
ForestGreen
|
||||
html = "228B22"
|
||||
Fuchsia
|
||||
html = "FF00FF"
|
||||
Gainsboro
|
||||
html = "DCDCDC"
|
||||
GhostWhite
|
||||
html = "F8F8FF"
|
||||
Gold
|
||||
html = "FFD700"
|
||||
GoldenRod
|
||||
html = "DAA520"
|
||||
Gray
|
||||
html = "808080"
|
||||
Green
|
||||
html = "008000"
|
||||
GreenYellow
|
||||
html = "ADFF2F"
|
||||
HoneyDew
|
||||
html = "F0FFF0"
|
||||
HotPink
|
||||
html = "FF69B4"
|
||||
IndianRed
|
||||
html = "CD5C5C"
|
||||
Indigo
|
||||
html = "4B0082"
|
||||
Ivory
|
||||
html = "FFFFF0"
|
||||
Khaki
|
||||
html = "F0E68C"
|
||||
Lavender
|
||||
html = "E6E6FA"
|
||||
LavenderBlush
|
||||
html = "FFF0F5"
|
||||
LawnGreen
|
||||
html = "7CFC00"
|
||||
LemonChiffon
|
||||
html = "FFFACD"
|
||||
LightBlue
|
||||
html = "ADD8E6"
|
||||
LightCoral
|
||||
html = "F08080"
|
||||
LightCyan
|
||||
html = "E0FFFF"
|
||||
LightGoldenRodYellow
|
||||
html = "FAFAD2"
|
||||
LightGrey
|
||||
html = "D3D3D3"
|
||||
LightGreen
|
||||
html = "90EE90"
|
||||
LightPink
|
||||
html = "FFB6C1"
|
||||
LightSalmon
|
||||
html = "FFA07A"
|
||||
LightSeaGreen
|
||||
html = "20B2AA"
|
||||
LightSkyBlue
|
||||
html = "87CEFA"
|
||||
LightSlateBlue
|
||||
html = "8470FF"
|
||||
LightSlateGray
|
||||
html = "778899"
|
||||
LightSteelBlue
|
||||
html = "B0C4DE"
|
||||
LightYellow
|
||||
html = "FFFFE0"
|
||||
Lime
|
||||
html = "00FF00"
|
||||
LimeGreen
|
||||
html = "32CD32"
|
||||
Linen
|
||||
html = "FAF0E6"
|
||||
Magenta
|
||||
html = "FF00FF"
|
||||
Maroon
|
||||
html = "800000"
|
||||
MediumAquaMarine
|
||||
html = "66CDAA"
|
||||
MediumBlue
|
||||
html = "0000CD"
|
||||
MediumOrchid
|
||||
html = "BA55D3"
|
||||
MediumPurple
|
||||
html = "9370D8"
|
||||
MediumSeaGreen
|
||||
html = "3CB371"
|
||||
MediumSlateBlue
|
||||
html = "7B68EE"
|
||||
MediumSpringGreen
|
||||
html = "00FA9A"
|
||||
MediumTurquoise
|
||||
html = "48D1CC"
|
||||
MediumVioletRed
|
||||
html = "C71585"
|
||||
MidnightBlue
|
||||
html = "191970"
|
||||
MintCream
|
||||
html = "F5FFFA"
|
||||
MistyRose
|
||||
html = "FFE4E1"
|
||||
Moccasin
|
||||
html = "FFE4B5"
|
||||
NavajoWhite
|
||||
html = "FFDEAD"
|
||||
Navy
|
||||
html = "000080"
|
||||
OldLace
|
||||
html = "FDF5E6"
|
||||
Olive
|
||||
html = "808000"
|
||||
OliveDrab
|
||||
html = "6B8E23"
|
||||
Orange
|
||||
html = "FFA500"
|
||||
OrangeRed
|
||||
html = "FF4500"
|
||||
Orchid
|
||||
html = "DA70D6"
|
||||
PaleGoldenRod
|
||||
html = "EEE8AA"
|
||||
PaleGreen
|
||||
html = "98FB98"
|
||||
PaleTurquoise
|
||||
html = "AFEEEE"
|
||||
PaleVioletRed
|
||||
html = "D87093"
|
||||
PapayaWhip
|
||||
html = "FFEFD5"
|
||||
PeachPuff
|
||||
html = "FFDAB9"
|
||||
Peru
|
||||
html = "CD853F"
|
||||
Pink
|
||||
html = "FFC0CB"
|
||||
Plum
|
||||
html = "DDA0DD"
|
||||
PowderBlue
|
||||
html = "B0E0E6"
|
||||
Purple
|
||||
html = "800080"
|
||||
Red
|
||||
html = "FF0000"
|
||||
RosyBrown
|
||||
html = "BC8F8F"
|
||||
RoyalBlue
|
||||
html = "4169E1"
|
||||
SaddleBrown
|
||||
html = "8B4513"
|
||||
Salmon
|
||||
html = "FA8072"
|
||||
SandyBrown
|
||||
html = "F4A460"
|
||||
SeaGreen
|
||||
html = "2E8B57"
|
||||
SeaShell
|
||||
html = "FFF5EE"
|
||||
Sienna
|
||||
html = "A0522D"
|
||||
Silver
|
||||
html = "C0C0C0"
|
||||
SkyBlue
|
||||
html = "87CEEB"
|
||||
SlateBlue
|
||||
html = "6A5ACD"
|
||||
SlateGray
|
||||
html = "708090"
|
||||
Snow
|
||||
html = "FFFAFA"
|
||||
SpringGreen
|
||||
html = "00FF7F"
|
||||
SteelBlue
|
||||
html = "4682B4"
|
||||
Tan
|
||||
html = "D2B48C"
|
||||
Teal
|
||||
html = "008080"
|
||||
Thistle
|
||||
html = "D8BFD8"
|
||||
Tomato
|
||||
html = "FF6347"
|
||||
Turquoise
|
||||
html = "40E0D0"
|
||||
Violet
|
||||
html = "EE82EE"
|
||||
VioletRed
|
||||
html = "D02090"
|
||||
Wheat
|
||||
html = "F5DEB3"
|
||||
White
|
||||
html = "FFFFFF"
|
||||
WhiteSmoke
|
||||
html = "F5F5F5"
|
||||
Yellow
|
||||
html = "FFFF00"
|
||||
YellowGreen
|
||||
html = "9ACD32"
|
||||
@@ -0,0 +1,161 @@
|
||||
/* sd_procs
|
||||
by: Shadowdarke (shadowdarke@hotmail.com)
|
||||
|
||||
A collection of general purpose procs I use often in
|
||||
other projects.
|
||||
|
||||
The following is a summary of all the procs and other additions included in
|
||||
the sd_procs library. Please refer to the specific file for detailed information.
|
||||
|
||||
|
||||
Atom (atom.dm)
|
||||
These procs expand on the basic built in procs.
|
||||
|
||||
Bumped(O)
|
||||
Automatically called whenever a movable atom O Bump()s into src.
|
||||
Proc protype designed to be overridden for specific objects.
|
||||
|
||||
Trigger(O)
|
||||
Automatically called whenever a movable atom O steps into the same
|
||||
turf with src.
|
||||
Proc protype designed to be overridden for specific objects.
|
||||
|
||||
|
||||
Base 64 (base64.dm)
|
||||
These procs convert plain text to a hexidecimal string to 64 encoded text and vice versa.
|
||||
|
||||
sd_base64toHex(encode64, pad_code = 67)
|
||||
Accepts a base 64 encoded text and returns the hexidecimal equivalent.
|
||||
|
||||
sd_hex2base64(hextext, pad_char = "=")
|
||||
Accepts a hexidecimal string and returns the base 64 encoded text equivalent.
|
||||
|
||||
sd_hex2text(hex)
|
||||
Accepts a hexidecimal string and returns the plain text equivalent.
|
||||
|
||||
sd_text2hex(txt)
|
||||
Accepts a plain text string and returns the hexidecimal equivalent.
|
||||
|
||||
|
||||
Colors(color.dm)
|
||||
sd_color
|
||||
sd_color is a special datum that contains color data in various
|
||||
formats. Sample colors are available in samplecolors.dm.
|
||||
VARS
|
||||
name // the name of the color
|
||||
red // red componant of the color
|
||||
green // green componant of the color
|
||||
blue // red componant of the color
|
||||
html // html string for the color
|
||||
icon/Icon // contains the icon produced by rgb2icon() proc
|
||||
|
||||
PROCS
|
||||
brightness()
|
||||
Returns the grayscale brightness of the RGB color set.
|
||||
|
||||
html2rgb()
|
||||
Calculates the rgb colors from the html colors.
|
||||
|
||||
rgb2html()
|
||||
Calculates the html color from the rbg colors.
|
||||
|
||||
rgb2icon()
|
||||
Converts the rgb value to a solid icon stored as src.Icon
|
||||
|
||||
Direction procs (direction.dm)
|
||||
sd_get_approx_dir(atom/ref,atom/target)
|
||||
returns the approximate direction from ref to target.
|
||||
|
||||
sd_degrees2dir(degrees as num)
|
||||
Accepts an angle in degrees and returns the closest BYOND
|
||||
direction value.
|
||||
|
||||
sd_dir2degrees(dir as num)
|
||||
Accepts a BYOND direction value and returns the angle North of
|
||||
East in degrees.
|
||||
|
||||
sd_dir2radial(dir as num)
|
||||
Accepts a BYOND direction value and returns the radial direction
|
||||
(0-7) North of East.
|
||||
|
||||
sd_dir2radians(dir as num)
|
||||
Accepts a BYOND direction value and returns the angle North of
|
||||
East in radians.
|
||||
|
||||
sd_dir2text(dir as num)
|
||||
Accepts a BYOND direction value and returns the lowercase text
|
||||
name of the direction.
|
||||
|
||||
sd_dir2Text(dir as num)
|
||||
Accepts a BYOND direction value and returns the Capitalized text
|
||||
name of the direction
|
||||
|
||||
sd_radial2dir(radial as num)
|
||||
Accepts a radial direction (0-7) and returns the BYOND direction
|
||||
value.
|
||||
|
||||
HSL procs (hsl.dm)
|
||||
hsl2rgb(hue, sat, lgh, scale = 240)
|
||||
Returns the RRGGBB format of an HSL color.
|
||||
ALTERNATE FORMAT: hsl2rgb(HSL, scale)
|
||||
|
||||
rgb2hsl(red, grn, blu, scale = 240)
|
||||
Returns the HHSSLL string of an RGB color
|
||||
ALTERNATE FORMAT: rgb2hsl(RGB, scale)
|
||||
|
||||
Math procs (math.dm)
|
||||
sd_base2dec(number as text, base = 16 as num)
|
||||
Accepts a number in any base (2 to 36) and returns the equivelent
|
||||
value in decimal.
|
||||
|
||||
sd_dec2base(decimal,base = 16 as num,digits = 0 as num)
|
||||
Accepts a decimal number and returns the equivelent value in the
|
||||
new base as a string.
|
||||
|
||||
sd_get_dist(atom/A, atom/B)
|
||||
Returns the mathematical 3D distance between two atoms.
|
||||
|
||||
sd_get_dist_squared(atom/A, atom/B)
|
||||
Returns the square of the mathematical 3D distance between two atoms. (More processor
|
||||
friendly than sd_get_dist() and useful for modelling realworld physics.)
|
||||
|
||||
Nybble Color procs (nybble.dm)
|
||||
sd_nybble2rgb(original, bit = 8, short = 0)
|
||||
Converts a nybble color to a hexidecimal RGB color string.
|
||||
|
||||
sd_rgb2nybble(rgb, bit = 8)
|
||||
Converts an RGB color string to a nybble color.
|
||||
|
||||
|
||||
Sample sd_colors. (samplecolors.dm)
|
||||
This file includes 142 predefined sd_colors. It will not automatically
|
||||
be included in your projects, since you may want to define them differently.
|
||||
|
||||
|
||||
Test program (test.dm)
|
||||
This file provides a brief demo of some library functions.
|
||||
It is not included in your projects.
|
||||
|
||||
|
||||
Text procs (text.dm)
|
||||
sd_findlast(maintext as text, searchtext as text)
|
||||
Returns the location of the last instance of searchtext in
|
||||
maintext. sd_findlast is not case sensitive.
|
||||
|
||||
sd_findLast(maintext as text, searchtext as text)
|
||||
Returns the location of the last instance of searchtext in
|
||||
maintext. sd_findLast is case sensitive.
|
||||
|
||||
sd_htmlremove(T as text)
|
||||
Returns the text string with all potential html tags (anything
|
||||
between < and >) removed.
|
||||
|
||||
sd_replacetext(maintext as text, oldtext as text, newtext as text)
|
||||
Replaces all instances of oldtext within maintext with newtext.
|
||||
sd_replacetext is not case sensitive.
|
||||
|
||||
sd_replaceText(maintext as text, oldtext as text, newtext as text)
|
||||
Replaces all instances of oldtext within maintext with newtext.
|
||||
sd_replaceText is case sensitive.
|
||||
|
||||
*/
|
||||
@@ -0,0 +1,89 @@
|
||||
/* Text procs
|
||||
These procs manipulate text strings.
|
||||
|
||||
sd_findlast(maintext as text, searchtext as text)
|
||||
Returns the location of the last instance of searchtext in
|
||||
maintext. sd_findlast is not case sensitive.
|
||||
|
||||
sd_findLast(maintext as text, searchtext as text)
|
||||
Returns the location of the last instance of searchtext in
|
||||
maintext. sd_findLast is case sensitive.
|
||||
|
||||
sd_htmlremove(T as text)
|
||||
Returns the text string with all potential html tags (anything
|
||||
between < and >) removed.
|
||||
|
||||
sd_replacetext(maintext as text, oldtext as text, newtext as text)
|
||||
Replaces all instances of oldtext within maintext with newtext.
|
||||
sd_replacetext is not case sensitive.
|
||||
|
||||
sd_replaceText(maintext as text, oldtext as text, newtext as text)
|
||||
Replaces all instances of oldtext within maintext with newtext.
|
||||
sd_replaceText is case sensitive.
|
||||
*/
|
||||
|
||||
/*********************************************
|
||||
* Implimentation: No need to read further. *
|
||||
*********************************************/
|
||||
proc
|
||||
sd_findlast(maintext as text, searchtext as text)
|
||||
/* Returns the location of the last instance of searchtext in
|
||||
maintext. sd_findlast is not case sensitive. */
|
||||
var/loc = 0
|
||||
var/looking = findtext(maintext, searchtext)
|
||||
while(looking)
|
||||
loc = looking
|
||||
looking = findtext(maintext, searchtext, looking + 1)
|
||||
return loc
|
||||
|
||||
sd_findLast(maintext as text, searchtext as text)
|
||||
/* Returns the location of the last instance of searchtext in
|
||||
maintext. sd_findLast is case sensitive. */
|
||||
var/loc = 0
|
||||
var/looking = findText(maintext, searchtext)
|
||||
while(looking)
|
||||
loc = looking
|
||||
looking = findText(maintext, searchtext, looking + 1)
|
||||
return loc
|
||||
|
||||
|
||||
sd_htmlremove(T as text)
|
||||
/* Returns the text string with all potential html tags (anything
|
||||
between < and >) removed. */
|
||||
T = sd_replacetext(T, " ","")
|
||||
var/open = findtext(T,"<")
|
||||
while(open)
|
||||
var/close = findtext(T,">",open)
|
||||
if(close)
|
||||
if(close<lentext(T))
|
||||
T = copytext(T,1,open)+copytext(T,close+1)
|
||||
else
|
||||
T = copytext(T,1,open)
|
||||
open = findtext(T,"<")
|
||||
else
|
||||
open = 0
|
||||
return T
|
||||
|
||||
sd_replacetext(maintext as text, oldtext as text, newtext as text)
|
||||
/* Replaces all instances of oldtext within maintext with newtext.
|
||||
sd_replacetext is not case sensitive. See sd_replaceText for a
|
||||
case sensitive version. */
|
||||
var/F = findtext(maintext, oldtext)
|
||||
var/length = length(newtext)
|
||||
while(F)
|
||||
var/newmessage = copytext(maintext,1,F) + newtext + copytext(maintext,F+lentext(oldtext))
|
||||
maintext = newmessage
|
||||
F = findtext(maintext, oldtext, F + length)
|
||||
return maintext
|
||||
|
||||
sd_replaceText(maintext as text, oldtext as text, newtext as text)
|
||||
/* Replaces all instances of oldtext within maintext with newtext.
|
||||
sd_replaceText is case sensitive. See sd_replacetext for a
|
||||
non-case sensitive version. */
|
||||
var/F = findText(maintext, oldtext)
|
||||
var/length = length(newtext)
|
||||
while(F)
|
||||
var/newmessage = copytext(maintext,1,F) + newtext + copytext(maintext,F+lentext(oldtext))
|
||||
maintext = newmessage
|
||||
F = findText(maintext, oldtext, F + length)
|
||||
return maintext
|
||||
Reference in New Issue
Block a user