function clear()
term.clear()
term.setCursorPos(1,1)
end
print("Rules: + is you, enemy is =, make sure to click the enemy to kill it!")
function attack(En)
if En == enemy then
print("You killed the enemy!")
return
end
if En == yourself then
print("You lose!")
return
end
end
function main()
clear()
term.setCursorPos(11,10)
print("+")
term.setCursorPos(10,11)
print("=")
local evt, button, x, y = os.pullEvent("mouse_click")
local tCoords = {
[1] (10, 11, 10, 11, "Enenemy", func = attack(enemy)),
[2] (11, 10, 11, 10, "Yourself", func = attack(yourself)),
}
for i = 1, #tCoords do
if x >= tCoords[i][1] and x <= tCoords[i][2] and y >= tCoords[i][3] and y <= tCoords[i][4] then
button = i
tCoords[i].func()
break
end
end
for i = 2, #tCoords do
if x >= tCoords[i][1] and x <= tCoords[i][2] and y >= tCoords[i][3] and y <= tCoords[i][4] then
button = i
tCoords[i].func()
break
end
end
end
main()