mirror of
https://github.com/vgstation-coders/vgstation13.git
synced 2025-12-10 18:32:03 +00:00
Removed var/constant/Pi It's already defined in setup.dm Moved a bunch of global_lists to global_lists.dm Fixed hair randomisation. (still bits to do) Moved a lot of preferences_setup.dm stuff into __HELPERS/mobs.dm They'll be FAR more helpful as generic procs, rather than something tied to preferences. Merged mob/var/nopush into status_flags with the CANPUSH flag Merged mob/var/nodamage into status_flags with the GODMODE flag Removed mob/var/be_syndicate and mob/var/be_random_name as they are not used. Added /proc/ui_style2icon(ui_style) proc. It converts a string like "Midnight" into its corresponding dmi file. The code fore creating a new hud uses it. git-svn-id: http://tgstation13.googlecode.com/svn/trunk@5164 316c924e-a436-60f5-8080-3fe189b3f50e
47 lines
1.3 KiB
Plaintext
47 lines
1.3 KiB
Plaintext
//general stuff
|
|
/proc/sanitize_integer(number, min=0, max=1, default=0)
|
|
if(isnum(number))
|
|
number = round(number)
|
|
if(min <= number && number <= max)
|
|
return number
|
|
return default
|
|
|
|
/proc/sanitize_text(text, default="")
|
|
if(istext(text))
|
|
return text
|
|
return default
|
|
|
|
/proc/sanitize_inlist(value, list/List, default)
|
|
if(value in List) return value
|
|
if(default) return default
|
|
if(List && List.len)return List[1]
|
|
|
|
|
|
|
|
//more specialised stuff
|
|
/proc/sanitize_gender(gender,neuter=0,plural=0, default="male")
|
|
switch(gender)
|
|
if(MALE, FEMALE)return gender
|
|
if(NEUTER)
|
|
if(neuter) return gender
|
|
else return default
|
|
if(PLURAL)
|
|
if(plural) return gender
|
|
else return default
|
|
return default
|
|
|
|
/proc/sanitize_hexcolor(color, default="#000000")
|
|
if(!istext(color)) return default
|
|
var/len = length(color)
|
|
if(len != 7 && len !=4) return default
|
|
if(text2ascii(color,1) != 35) return default //35 is the ascii code for "#"
|
|
. = "#"
|
|
for(var/i=2,i<=len,i++)
|
|
var/ascii = text2ascii(color,i)
|
|
switch(ascii)
|
|
if(48 to 57) . += ascii2text(ascii) //numbers 0 to 9
|
|
if(97 to 102) . += ascii2text(ascii) //letters a to f
|
|
if(65 to 70) . += ascii2text(ascii+32) //letters A to F - translates to lowercase
|
|
else return default
|
|
return .
|