This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
grazazel's profile picture

[1.3]is this possible please

Started by grazazel, 10 October 2012 - 11:26 PM
grazazel #1
Posted 11 October 2012 - 01:26 AM
Hi I am a total noob but what i want to know is it possible to have a menu on computer that when you make a selection will run a certain program on attached monitors, for example if I wanted a sign for a shop that i could just go into the menu and select shop open or closed so it would print whether the shop was open or closed on monitor, without the menu showing on the monitors. any heklp would be appreciated
Lyqyd #2
Posted 11 October 2012 - 01:44 AM
Yep. Just look into the term and peripheral APIs. Specifically, peripheral.wrap() and term.redirect()/term.restore(). This is a pretty simple thing you're asking; the most complex part would be the menu, depending on how fancy you want to get with it. A bit of basic research should get you started on the monitor output part, and there are plenty of menu APIs out there, so you may be able to find one you like if you don't feel like coding one yourself.
trynothingy #3
Posted 14 October 2012 - 04:23 PM
Yes It Is Possible And Is Easy To Make, Infact I Have Made It.
PasteBin URL : http://pastebin.com/5m3BWsyz
PasteBin ID :
5m3BWsyz

Raw Code :
Spoilerside = "back" –Replace back with the side your monitor is on
open = "text" – Replace text with what you want the monitor to say when it your shop is open
close = "text" – Replace text with what you want the monitor to say when it your shop is closed
mon = peripheral.wrap(side)

term.clear()
term.setCursorPos(1,1)

function yN()
local n=1
while true do
local x, y=term.getCursorPos()
term.clearLine()
if n==1 then write(">Open< Close") else write (" Open >Close<") end
term.setCursorPos(x, y)
a, b=os.pullEvent()
while a~="key" do a, b=os.pullEvent() end
if b==203 and n==2 then n=1 end
if b==205 and n==1 then n=2 end
if b==28 then print("") break end
end
if n==1 then
mon.clear()
mon.setCursorPos(1,1)
mon.write(open)
term.clear()
term.setCursorPos(1,1)
yN()
end

if n==2 then
mon.setCursorPos(1,1)
mon.write(close)
term.clear()
term.setCursorPos(1,1)
yN()
end

return false
end

yN()
ardera #4
Posted 14 October 2012 - 05:36 PM
almost everything is possible with programming languanges.