script.md
Here I'll share some little scripts that can make life a little easier, while building your more complex scripts.
# Creature Comfort Scripts Here I'll share some little scripts that can make life a little easier, while building your more complex scripts.
ext.string_colors.src
string.__colors = {
"dark_gray": "#A0A0A0", // Dark Gray for secondary text
"light_gray": "#D3D3D3", // Light Gray for highlights
"cyan": "#00FFFF", // Cyan for info
"light_green": "#90EE90", // Light Green for success
"yellow": "#FFFF00", // Yellow for warnings
"soft_blu": "#ADD8E6", // Soft Blue for links
"soft_purple": "#DDA0DD", // Soft Purple for special messages
"dark_green": "#006400", // Dark Green for directories
"brown": "#8B4513", // Brown for archival files
"white": "#FFFFFF", // White for main text
"red": "#FF0000"} // Red for root
// Extend string with color() & c()
string.color = function(self, colorString)
if self.__colors.hasIndex(colorString) then
return "<color=" + self.__colors[colorString] + ">" + self + "</color>"
else if colorString.matches("\#[a-fA-F0-9]{6}") then
return "<color=" + colorString + ">" + self + "</color>"
else if colorString.matches("\#[a-fA-F0-9]{3}") then
return "<color=#" + colorString[1]*2 + colorString[2]*2 + colorString[3]*2 + ">" + self + "</color>"
end if
return self // return plain string when nothing matches as a color
end function
string.c = @string.color
// Extend string with bold() & b()
string.bold = function(self)
return "<b>" + self + "</b>"
end function
string.b = @string.bold
// Extend string with italic() & i()
string.italic = function(self)
return "<i>" + self + "</i>"
end function
string.i = @string.italic
// Extend string with underline() & i()
string.underline = function(self)
return "<u>" + self + "</u>"
end function
string.u = @string.underline
// Extend string with strikethrough() & s()
string.strikethrough = function(self)
return "<s>" + self + "</s>"
end function
string.s = @string.strikethrough
// Usage example
clear_screen()
print("This ".c("yellow") + "string".b + " " + ("should".c("#FFF") + " be").s.i + " in " + "multicolor".i.u.c("#F00"))
print("This string " + "should".c("#NonExistantColor") + " be basic")