I don't really understand functions,thats why I used the loadstring() so can you explain it a bit more? (Im a newbie xD)
if you don't understand functions then you probably shouldn't be using loadstring.
a function allows us to run a sequence of instructions multiple times without needing to write them each time, every time you see a set of parenthesis this is what is known as a function call, that is, we're going to run the instructions within the function.
for example we can define a function like this
local function clear()
term.setBackgroundColor(colors.black)
term.clear()
term.setCursorPos(1, 1)
end
and each time we call the function with clear() the Computer's screen will be turned completely black and the cursor will move to the top left corner. therefore we use functions to reduce duplicate code. we can also supply arguments/parameters to some functions for use; this can be seen when you use term.setCursorPos and supply it with two numbers, these numbers (or parameters) are where you wish the cursor to move. To do that you simply add a variable name between the parenthesis when creating the function, and then giving a value when you call the function. Example
local function printColored(text, textColor)
term.setTextColor(textColor)
print(text)
end
printColored("Hello world", colors.green)
printColored("Goodbye world", colors.red)
hopefully you can see that the above will help you severely reduce your code down.
As for using the peripheral methods direcly, I would rather type
MonitorColorRed,MonitorColorRed,MonitorColorRed,MonitorColorRed than
Monitor.setTextColor(colors.red),Monitor.setTextColor(colors.red),Monitor.setTextColor(colors.red),Monitor.setTextColor(colors.red)
well that's not really the case, you've done
Monitor.setTextColor(colors.yellow) a few times. If you'd prefer it shorter perhaps you should do a function like this
local function color(c)
Monitor.setTextColor(c)
end
then you can simply type
color(colors.red) or
color(colors.yellow)