repeat
event,p1 = os.pullEvent()
stuff
until event=="char" and p1==("x")
Replace "x" with whatever key you want.Or does it have to work with "any key"?
There have been 15 items by RickiHN (Search limited from 10-February 22)
Posted by
RickiHN
on 17 August 2014 - 05:26 PM
in
Ask a Pro
Cranium, on 17 August 2014 - 05:21 PM, said:
Posted by
RickiHN
on 16 August 2014 - 07:14 PM
in
Ask a Pro
Yevano, on 16 August 2014 - 06:18 PM, said:
buttontext = {}
buttontext[1]="Floor 1 "
buttontext[2]="Floor 2 "
buttontext[3]="Floor 3 "
buttontext[4]="Floor 4 "
buttontext[5]="Floor 5 "
buttontext[6]="Floor 6 "
buttontext[7]="Floor 7 "
buttontext[8]="Floor 8 "
buttontext[9]="Floor 9 "
shell.run("rm", "elevator")
shell.run("pastebin", "get", "1M5sgXpT", "elevator")
os.loadAPI("elevator")
elevator.elevator(buttontext)
function elevator(buttontext)
--Load floor location from disk
local FloorFile = fs.open("disk/floor", "r")
if FloorFile then
ThisFloor = tonumber(FloorFile.readLine())
print("This floor: "..ThisFloor)
FloorFile.close()
else
print("No Floor File/disk found")
return
end
os.setComputerLabel("Elevator"..ThisFloor)
buttoncolours={}
for k=1, #buttontext do
buttoncolours[k]=8192 --8192=green
end
buttoncolours[ThisFloor]=32 --32=lime
mouseWidth = 0
mouseHeight = 0
monitor = peripheral.wrap("bottom")
monitor.clear()
monitor.setCursorPos(1,1)
w,h=monitor.getSize()
print(w)
print(h)
--Draw buttons
for k=1, #buttontext do
monitor.setBackgroundColour((buttoncolours[k]))
monitor.setCursorPos(2,k*2)
monitor.write(buttontext[k])
monitor.setBackgroundColour((colours.black))
end --for
repeat
event,p1,p2,p3 = os.pullEvent()
if event=="monitor_touch" then
mouseWidth = p2 -- sets mouseWidth
mouseHeight = p3 -- and mouseHeight
for k=1, #buttontext do
if mouseWidth > 1 and mouseWidth < 18 and mouseHeight == k*2 and k~=ThisFloor then
redstone.setOutput("top", true)
sleep(1)
redstone.setAnalogOutput("back", k)
sleep(2)
redstone.setOutput("top", false)
redstone.setAnalogOutput("back", 0)
end
end
end
until event=="char" and p1==("x")
end
Posted by
RickiHN
on 16 August 2014 - 06:18 PM
in
Programs

Posted by
RickiHN
on 16 August 2014 - 05:54 PM
in
Programs
Win7yes, on 16 August 2014 - 05:41 PM, said:
Posted by
RickiHN
on 16 August 2014 - 05:41 PM
in
Ask a Pro
buttons = {}
buttons[1]="Floor 1 "
buttons[2]="Floor 2 "
buttons[3]="Floor 3 "
buttons[4]="Floor 4 "
buttons[5]="Floor 5 "
buttons[6]="Floor 6 "
buttons[7]="Floor 7 "
buttons[8]="Floor 8 "
buttons[9]="Floor 9 "
shell.run("rm", "elevator")
shell.run("pastebin", "get", "1M5sgXpT", "elevator")
shell.run("elevator")
local buttontext = {}
os.loadAPI("startup")
buttontext = startup.buttons
os.unloadAPI("startup")
--Load floor location from disk
local FloorFile = fs.open("disk/floor", "r")
if FloorFile then
ThisFloor = tonumber(FloorFile.readLine())
print("This floor: "..ThisFloor)
FloorFile.close()
else
print("No Floor File/disk found")
return
end
os.setComputerLabel("Elevator"..ThisFloor)
local buttoncolours={}
for k=1, #buttontext do
buttoncolours[k]=8192 --8192=green
end
buttoncolours[ThisFloor]=32 --32=lime
mouseWidth = 0
mouseHeight = 0
monitor = peripheral.wrap("bottom")
monitor.clear()
monitor.setCursorPos(1,1)
w,h=monitor.getSize()
print(w)
print(h)
--Draw buttons
for k=1, #buttontext do
monitor.setBackgroundColour((buttoncolours[k]))
monitor.setCursorPos(2,k*2)
monitor.write(buttontext[k])
monitor.setBackgroundColour((colours.black))
end --for
function checkClickPosition()
for k=1, #buttontext do
if mouseWidth > 1 and mouseWidth < 18 and mouseHeight == k*2 and k~=ThisFloor then
redstone.setOutput("top", true)
sleep(1)
redstone.setAnalogOutput("back", k)
sleep(2)
redstone.setOutput("top", false)
redstone.setAnalogOutput("back", 0)
end
end
end
repeat
event,p1,p2,p3 = os.pullEvent()
if event=="monitor_touch" then
mouseWidth = p2 -- sets mouseWidth
mouseHeight = p3 -- and mouseHeight
checkClickPosition() -- this runs our function
end
until event=="char" and p1==("x")
Quote
Posted by
RickiHN
on 16 August 2014 - 04:43 PM
in
Programs
secret6timb1, on 08 August 2014 - 11:51 PM, said:
Posted by
RickiHN
on 16 August 2014 - 02:41 PM
in
Ask a Pro
Yevano, on 16 August 2014 - 02:24 PM, said:
local withquotes = { }
for i = 1, 9 do
withquotes[i] = '"' .. buttontext[i] .. '"'
end
shell.run("elevator", unwrap(withquotes))
should work.
Link149, on 16 August 2014 - 02:38 PM, said:
os.loadApi("somefile")
Posted by
RickiHN
on 16 August 2014 - 01:46 PM
in
Ask a Pro
local buttontext = {}
buttontext[1]="Floor 1 "
buttontext[2]="Floor 2 "
buttontext[3]="Floor 3 "
buttontext[4]="Floor 4 "
buttontext[5]="Floor 5 "
buttontext[6]="Floor 6 "
buttontext[7]="Floor 7 "
buttontext[8]="Floor 8 "
buttontext[9]="Floor 9 "
shell.run("rm", "elevator")
shell.run("pastebin", "get", "1M5sgXpT", "elevator")
shell.run("elevator", buttontext[1], buttontext[2], buttontext[3], buttontext[4], buttontext[5], buttontext[6], buttontext[7], buttontext[8], buttontext[9])
local buttontext = {...}
--Load floor location from disk
local FloorFile = fs.open("disk/floor", "r")
if FloorFile then
ThisFloor = tonumber(FloorFile.readLine())
print("This floor: "..ThisFloor)
FloorFile.close()
else
print("No Floor File/disk found")
return
end
os.setComputerLabel("Elevator"..ThisFloor)
local buttoncolours={}
for k=1, #buttontext do
buttoncolours[k]=8192 --8192=green
end
buttoncolours[ThisFloor]=32 --32=lime
mouseWidth = 0
mouseHeight = 0
monitor = peripheral.wrap("bottom")
monitor.clear()
monitor.setCursorPos(1,1)
w,h=monitor.getSize()
print(w)
print(h)
--Draw buttons
for k=1, #buttontext do
monitor.setBackgroundColour((buttoncolours[k]))
monitor.setCursorPos(2,k*2)
monitor.write(buttontext[k])
monitor.setBackgroundColour((colours.black))
end --for
function checkClickPosition()
for k=1, #buttontext do
if mouseWidth > 1 and mouseWidth < 18 and mouseHeight == k*2 and k~=ThisFloor then
redstone.setOutput("top", true)
sleep(1)
redstone.setAnalogOutput("back", k)
sleep(2)
redstone.setOutput("top", false)
redstone.setAnalogOutput("back", 0)
end
end
end
repeat
event,p1,p2,p3 = os.pullEvent()
if event=="monitor_touch" then
mouseWidth = p2 -- sets mouseWidth
mouseHeight = p3 -- and mouseHeight
checkClickPosition() -- this runs our function
end
until event=="char" and p1==("x")
