Posted 17 March 2013 - 07:34 AM
i can't find any good tutorial or topic that explains me how to work with advanced computers.
i would like to learn how to making a touch screen button for instance that flashes from red to green when you touch it.
and how do i make a controll panel in wich i can go torugh the option to turn somthing on and off with the arrow and enter keys coloring from for instance red to green(on off)
if somone could explain to me in detail how this work it would be nice.
i also want to know how i use table in functions to make it like an api to make this script smaller for instance
thank you verry much in advance
max munte,
i would like to learn how to making a touch screen button for instance that flashes from red to green when you touch it.
and how do i make a controll panel in wich i can go torugh the option to turn somthing on and off with the arrow and enter keys coloring from for instance red to green(on off)
if somone could explain to me in detail how this work it would be nice.
i also want to know how i use table in functions to make it like an api to make this script smaller for instance
Spoiler
if turtle.getFuelLevel() < 1000 then
turtle.select(16)
turtle.refuel(10)
end
while turtle.detectDown() == false do
turtle.down()
end
turtle.up()
term.clear()
term.setCursorPos(1,1)
print("how wide should the house be?")
write("enter a number : ")
local var1 = tonumber(read())
term.clear()
term.setCursorPos(1,1)
print("how long should the house be?")
write("enter a number : ")
local var2 = tonumber(read())
term.clear()
term.setCursorPos(1,1)
print("how high should the house be?")
write("enter a number : ")
local var3 = tonumber(read())
local var1 = tonumber(var1 - 2)
local var2 = tonumber(var2 - 2)
local totali = (((var1+var2)*2)*var3)+(var3*4)+(var1*var2)
local print1 = ((var1+var2)*2)*var3
local print2 = var3*4
local print3 = var1*var2
term.clear()
term.setCursorPos(1,1)
print("---------------------------------------")
print("row 1 = wall, row 2 = corners, row 3 = roof")
print("---------------------------------------")
print("items required row 1: ", print1)
print("items required row 2: ", print2)
print("items required row 2: ", print3)
print("---------------------------------------")
print("total items required: ", totali)
print("---------------------------------------")
print("press any key to continue")
event1, param1 = os.pullEvent()
term.clear()
term.setCursorPos(1,1)
print("calculating")
local getItem1 = tonumber(turtle.getItemCount(1) + turtle.getItemCount(2) + turtle.getItemCount(3) + turtle.getItemCount(4))
local itemState1 = false
local need1 = 0
term.clear()
term.setCursorPos(1,1)
if getItem1 < print1 and getItem1 < 256 then
while itemState1 == false do
if getItem1 > 256 then need1 = tonumber(256) else need1 = tonumber(print1) end
if getItem1 < print1 and getItem1 < 256 then
sleep(0.2)
itemState1 = false
term.clear()
term.setCursorPos(1,1)
print("need more resources in row 1 to be able to finish this build")
print("---------------------------------------")
print("items in inventory: ",getItem1)
print("you require atleast: ",need1)
print("still needed: ",need1 - getItem1)
print("---------------------------------------")
getItem1 = tonumber(turtle.getItemCount(1) + turtle.getItemCount(2) + turtle.getItemCount(3) + turtle.getItemCount(4))
else
term.clear()
term.setCursorPos(1,1)
print("need more resources in row 1 to be able to finish this build")
print("---------------------------------------")
print("items in inventory: ",getItem1)
print("you require atleast: ",need1)
print("still needed: ",need1 - getItem1)
print("---------------------------------------")
print("press any key to continue")
itemState1 = true
event1, param1 = os.pullEvent()
sleep(1)
end
end
end
local getItem2 = tonumber(turtle.getItemCount(5) + turtle.getItemCount(6) + turtle.getItemCount(7) + turtle.getItemCount(8))
local itemState2 = false
local need2 = 0
if getItem2 < print2 and getItem2 < 256 then
while itemState2 == false do
if getItem2 > 256 then need2 = tonumber(256) else need2 = tonumber(print2) end
if getItem2 < print2 and getItem2 < 256 then
sleep(0.2)
itemState2 = false
term.clear()
term.setCursorPos(1,1)
print("need more resources in row 2 to be able to finish this build")
print("---------------------------------------")
print("items in inventory: ",getItem2)
print("you require atleast: ",need2)
print("still needed: ",need2 - getItem2)
print("---------------------------------------")
getItem2 = tonumber(turtle.getItemCount(5) + turtle.getItemCount(6) + turtle.getItemCount(7) + turtle.getItemCount(8))
else
term.clear()
term.setCursorPos(1,1)
print("need more resources in row 2 to be able to finish this build")
print("---------------------------------------")
print("items in inventory: ",getItem2)
print("you require atleast: ",need2)
print("still needed: ",need2 - getItem2)
print("---------------------------------------")
print("press any key to continue")
itemState2 = true
event1, param1 = os.pullEvent()
sleep(1)
end
end
end
local getItem3 = tonumber(turtle.getItemCount(9) + turtle.getItemCount(10) + turtle.getItemCount(11) + turtle.getItemCount(12))
local itemState3 = false
local need3 = 0
if getItem3 < print3 and getItem3 < 256 then
while itemState3 == false do
if getItem3 > 256 then need3 = tonumber(256) else need3 = tonumber(print3) end
if getItem3 < print3 and getItem3 < 256 then
sleep(0.2)
itemState3 = false
term.clear()
term.setCursorPos(1,1)
print("need more resources in row 3 to be able to finish this build")
print("---------------------------------------")
print("items in inventory: ",getItem3)
print("you require atleast: ",need3)
print("still needed: ",need3 - getItem3)
print("---------------------------------------")
getItem3 = tonumber(turtle.getItemCount(9) + turtle.getItemCount(10) + turtle.getItemCount(11) + turtle.getItemCount(12))
else
term.clear()
term.setCursorPos(1,1)
print("need more resources in row 3 to be able to finish this build")
print("---------------------------------------")
print("items in inventory: ",getItem3)
print("you require atleast: ",need3)
print("still needed: ",need3 - getItem3)
print("---------------------------------------")
print("press any key to continue")
itemState3 = true
event1, param1 = os.pullEvent()
sleep(1)
end
end
end
term.clear()
term.setCursorPos(1,1)
print("starting to build")
function antiObstruct()
if turtle.detectDown() then
turtle.digDown()
end
if turtle.detect() then
turtle.dig()
end
end
function refillMain()
if turtle.getItemCount(1) < 1 then
if turtle.getItemCount(2) < 1 then
if turtle.getItemCount(3) < 1 then
if turtle.getItemCount(4) < 1 then
while turtle.getItemCount(1) < 1 do
print("need more resources to continue, refill resources")
print("press any key to continue")
event1, param1 = os.pullEvent()
turtle.select(2)
turtle.transferTo(1)
turtle.select(3)
turtle.transferTo(1)
turtle.select(4)
turtle.transferTo(1)
term.clear()
term.setCursorPos(1,1)
end
else
turtle.select(2)
turtle.transferTo(1)
turtle.select(3)
turtle.transferTo(1)
turtle.select(4)
turtle.transferTo(1)
end
else
turtle.select(2)
turtle.transferTo(1)
turtle.select(3)
turtle.transferTo(1)
end
else
turtle.select(2)
turtle.transferTo(1)
end
end
end
function refillSecundairy()
if turtle.getItemCount(5) < 1 then
if turtle.getItemCount(6) < 1 then
if turtle.getItemCount(7) < 1 then
if turtle.getItemCount(8) < 1 then
while turtle.getItemCount(5) < 1 do
print("need more resources to continue, refill resources")
print("press any key to continue")
event1, param1 = os.pullEvent()
turtle.select(6)
turtle.transferTo(5)
turtle.select(7)
turtle.transferTo(5)
turtle.select(8)
turtle.transferTo(5)
term.clear()
term.setCursorPos(1,1)
end
else
turtle.select(6)
turtle.transferTo(5)
turtle.select(7)
turtle.transferTo(5)
turtle.select(8)
turtle.transferTo(5)
end
else
turtle.select(6)
turtle.transferTo(5)
turtle.select(7)
turtle.transferTo(5)
end
else
turtle.select(6)
turtle.transferTo(5)
end
end
end
function refillTertiary()
if turtle.getItemCount(9) < 1 then
if turtle.getItemCount(10) < 1 then
if turtle.getItemCount(11) < 1 then
if turtle.getItemCount(12) < 1 then
while turtle.getItemCount(9) < 1 do
print("need more resources to continue, refill resources")
print("press any key to continue")
event1, param1 = os.pullEvent()
turtle.select(10)
turtle.transferTo(9)
turtle.select(11)
turtle.transferTo(9)
turtle.select(12)
turtle.transferTo(9)
turtle.select(9)
term.clear()
term.setCursorPos(1,1)
end
else
turtle.select(10)
turtle.transferTo(9)
turtle.select(11)
turtle.transferTo(9)
turtle.select(12)
turtle.transferTo(9)
turtle.select(9)
end
else
turtle.select(10)
turtle.transferTo(9)
turtle.select(11)
turtle.transferTo(9)
turtle.select(9)
end
else
turtle.select(10)
turtle.transferTo(9)
turtle.select(9)
end
end
end
sleep(4)
term.clear()
print("building")
for n=1,1 do
for i=1,var3 do
for j=1,2 do
for k=1,var2 do
turtle.select(1) -- building main wall
antiObstruct()
turtle.placeDown()
refillMain()
turtle.forward()
end
turtle.turnLeft() -- building corner
turtle.select(5)
antiObstruct()
turtle.placeDown()
refillSecundairy()
turtle.forward()
for l=1,var1 do
turtle.select(1) -- building main wall
antiObstruct()
turtle.placeDown()
refillMain()
turtle.forward()
end
turtle.turnLeft() -- building corner
turtle.select(5)
antiObstruct()
turtle.placeDown()
refillSecundairy()
turtle.select(1)
turtle.forward()
end
turtle.up()
end
turtle.turnLeft()
turtle.forward()
turtle.turnRight()
turtle.select(9)
turtle.down()
turtle.placeDown()
turtle.forward()
local roofvar = tonumber(var1 / 2)
local var2 = tonumber(var2 - 2)
for o=1,roofvar do -- building roof
for p=1,var2 do
antiObstruct()
turtle.placeDown()
refillTertiary()
turtle.forward()
end
turtle.turnLeft() -- Turning back
antiObstruct()
turtle.placeDown()
refillTertiary()
turtle.forward()
turtle.turnLeft()
antiObstruct()
turtle.placeDown()
refillTertiary()
turtle.forward()
for p=1,var2 do -- building roof
antiObstruct()
turtle.placeDown()
refillTertiary()
turtle.forward()
end
turtle.turnRight() -- Turning back
antiObstruct()
turtle.placeDown()
refillTertiary()
turtle.forward()
turtle.turnRight()
antiObstruct()
turtle.placeDown()
turtle.forward()
end
for p=1,var2 do -- building roof
turtle.placeDown()
refillTertiary()
turtle.forward()
end
end
turtle.placeDown()
turtle.turnLeft()
turtle.forward()
turtle.forward()
turtle.turnLeft()
for n=1,var3 do
turtle.down()
end
local var2 = tonumber(var2 - 1)
for q=1,var2 do
if turtle.detect() then
turtle.dig()
end
turtle.forward()
end
turtle.turnLeft()
turtle.turnLeft()
term.clear()
term.setCursorPos(1,1)
print("Done!")
event1, param1 = os.pullEvent()
thank you verry much in advance
max munte,