Posted 31 August 2016 - 06:28 AM
I just have a question. I want to make a program, whose function is to test your nickname using the normal minecraft color codes. For example, they would type in "&5Jack" I'm struggling with how to get it to recognize the &5, then set the color to whatever color that is, then write Jack in that color. And once I get that, maybe there is away to recognize multi-color. for example "&5J&6a&6c&k"
Regardless of the color codes, is there anyway I could accomplish this?
Update:
I decided to take a completely different approach. Here is my code
Alas, another update:
Derp. For some reason, didn't like left click.
Regardless of the color codes, is there anyway I could accomplish this?
Update:
I decided to take a completely different approach. Here is my code
---------------------------------------
function writeText(xPos, yPos, b_color, t_color, text)
term.setCursorPos(xPos, yPos)
term.setBackgroundColor(b_color)
term.setTextColor(t_color)
term.write(text)
end
function writeLine(xPos, yPos, color)
x, y = term.getSize()
term.setCursorPos(xPos, yPos)
term.setBackgroundColor(color)
term.write(string.rep(" ", x))
end
function clear()
term.setBackgroundColor(colors.white)
term.clear()
end
function home()
clear()
x, y = term.getSize()
writeLine(1, 1, colors.purple)
writeLine(1, y, colors.purple)
writeText(1, 1, colors.purple, colors.white, "Jackson's Nickname Designer")
writeText(2, 2, colors.white, colors.black, "&0")
writeText(5, 2, colors.white, colors.blue, "&1")
writeText(8, 2, colors.white, colors.green, "&2")
writeText(11, 2, colors.white, colors.cyan, "&3")
end
home()
--------------------------------------
button, xPos, yPos = os.pullEvent("mouse_click")
if xPos == 2 and yPos == 2 then
term.setTextColor(colors.black)
term.setBackgroundColor(colors.white)
term.setCursorPos(1, 3)
wait = read()
else
write("you done didn't click right")--Troubleshooting
end
Anyways, it has the '&' codes on screen for the user to click on. I'm running into one issue. And although it's the simplest i'm sure, i'm stuck. For some reason, when I click 2 (x), 2 (y), it goes to the else. As if I didn't click in the right spot. And I have no clue why. It's my understanding x and y are as follow, (x, y) where x is across the top horizontally, while y runs down vertically. I know the code works if I do for example "if "mouse_click" then (code) and it works just fine. What am I overlooking?Alas, another update:
Derp. For some reason, didn't like left click.
Edited on 31 August 2016 - 11:46 PM