THE APPLICATION CODE[VERY messy]
Spoiler
term.clear() term.setCursorPos(1,1)
isx="1"
--game: tower defence
--FUNCTIONS
fs.delete("TDGchache") ;
function write(text)
term.write(text)
end
function newTower( x, y )
term.setCursorPos(x,y)
write("T")
--TABLES and USEABLE version
towsx = {}
towsx[isx] = x
towsy = {}
towsy[isx] = y
print(isx)
isx= isx + 1
end
--
--[[towx.."isx" = ""..x..""
towy.."isx" = ""..y..""
isx = "isx + 1"--]]
--[[addt = fs.open("TDGchache", "a") ;
addt.writeLine(""..x.." "..y.."")
addt.close()--]]
menuClicks()
end
function placeTower()
_, button, o, t = os.pullEvent ("mouse_click") ;
if t ==10 then
placeTower()
elseif t ==11 then
placeTower()
elseif t ==12 then
placeTower()
elseif t ==19 then
placeTower()
elseif t ==18 then
placeTower()
else
newTower( o, t ) ;
end
end
function drawPath()
term.setCursorPos(1,10)
lineE = "-----------------------------------------------------"
term.write(""..lineE.."") ;
term.setCursorPos(1, 12)
term.write(""..lineE.."") ;
drawMenu()
end
function drawMenu()
term.setCursorPos(1,18)
term.write(""..lineE.."") ;
term.setCursorPos(1,19)
term.write("Buy tower Sell Tower") ; --9
end
function menuClicks()
_2, button2, x2, y2 = os.pullEvent ("mouse_click") ;
if y2 ==19 and x2 <9 then
placeTower()
elseif y2 ==19 and x2 >9 and x2 <19 then
print("hi") ;
else
menuClicks()
end
end
--[[Notes:
Need a menu bar function w/ "add a tower"
--]]
drawPath()
placeTower()












