66 posts
Posted 24 July 2012 - 07:56 AM
hello i want to know how to make it so when when u push the up button the 2 arrows move up for example. the arrows are at "Dcleondc's World" and when i pushed the up arrow it would go to "Frame Quarry" and when i pushed enter it would do code for when i selected "Frame Quarry". if someone could tell me how or add me on skype so i can explain it more and you could make the code that would be awesome. my skype is dcleondc
992 posts
Posted 24 July 2012 - 08:35 AM
can we get a look at the back of that (see how you have wired it) if yes then i think I can help ya. else ?? end
864 posts
Location
Sometime.
Posted 24 July 2012 - 08:44 AM
Just use a lot of if's and elseif's.
With the colors api.
992 posts
Posted 24 July 2012 - 09:16 AM
This should be what you are looking for. Next question is what do you want it to do after it is selected ?
Spoiler
local bundelSide = "bottom"
local colorUp = "white"
local colorDown = "magenta"
local colorEnter = "orange"
local function menu(...) -- ver 0.1
local sel = 1
local list = {...}
local offX,offY = term.getCursorPos()
local curX,curY = term.getCursorPos()
while true do
if sel > #list then sel = 1 end
if sel < 1 then sel = #list end
for i = 1,#list do
term.setCursorPos(offX,offY+i-1)
if sel == i then
print("->"..list[i].."<-")
else
print(list[i].." ")
end
end
while true do
local e,e1,e2,e3,e4,e5 = os.pullEvent()
if e == "redstone" then
local iInput = rs.getBundledInput(bundelSide)
if colors.test(iInput,colors[colorUp]) then
sel = sel-1
break
elseif colors.test(iInput,colors[colorDown]) then
sel = sel+1
break
elseif colors.test(iInput,colors[colorEnter]) then
term.setCursorPos(curX,curY)
return list[sel],sel
end
end
--[[if e == "key" then
if e1 == 200 then -- up key
sel = sel-1
break
end
if e1 == 208 then -- down key
sel = sel+1
break
end
if e1 == 28 then
term.setCursorPos(curX,curY)
return list[sel],sel
end
end--]]
end
end
end
term.clear()
term.setCursorPos(1,1)
print("Please select a world")
local selection = menu("Strip Mine","Frame Quarry","Dcleondc's world","Laxman69j's world","Nether","Mushroom Kindom")
term.clear()
term.setCursorPos(1,1)
print("User Selected : "..selection)
864 posts
Location
Sometime.
Posted 24 July 2012 - 09:18 AM
I see what you did thar. colorsUp - Very Clever.
As for the selection = menu( .. blah .. ) where is the print for all options?
992 posts
Posted 24 July 2012 - 09:39 AM
I see what you did thar. colorsUp - Very Clever.
As for the selection = menu( .. blah .. ) where is the print for all options?
if you mean where is the section of code that prints the options to the screen look at the for loop starting at line 13. all options are takes into a table then printed in turn on each line. if else please please clarify question end
864 posts
Location
Sometime.
Posted 24 July 2012 - 09:43 AM
Ohh I see, it redraws every time you change.
Nvm..
236 posts
Location
Germany
Posted 24 July 2012 - 12:34 PM
i shoud have something like this in my pastebin jup there we go:
http://pastebin.com/LP4AhxN5