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

("Help") Little Array Output problem

Started by Radioaktiv3, 28 November 2012 - 12:44 AM
Radioaktiv3 #1
Posted 28 November 2012 - 01:44 AM
The Code should give me an output with


…..
Menu item
Menu item
Menu item

it also will make a selection mark difind by a string but if i read out the array in cobination with the mark

he will show no selection but a "/" with the MenuItem behind it, why ?



selected = 1
maxEintrag = 3
selectedsymbol = ">> "
reboot = false
pressedOk = 0

term.clear()
local menuEintrage = {"a","b","Exit","d","e"}

function draw()

x = 1
term.clear()
term.setCursorPos(1,1)
while x < maxEintrag + 1 do
if selected == x then
print(fs.combine(selectedsymbol, menuEintrage[x]))
else
print(menuEintrage[x])
end
x = x + 1
end
end

draw()

function click()

if selected == 1 then

end
if slected == 2 then

end

end

repeat
none, key = os.pullEvent ("key")
if key == 208 then
selected = selected + 1
if selected > maxEintrag then
selected = 1
end
draw()
end
if key == 200 then
selected = selected-1
if selected <= 0 then
selected = maxEintrag
end
draw()
end

if key == 28 then
click()
end

until reboot == true

Sry for my English ….. i am German ;D
Radioaktiv3 #2
Posted 28 November 2012 - 02:54 AM
I found my fail its that i us fs.combine its for filesystems not for string.combination
ok i only want let you know that ;D


[CLOSED]
KaoS #3
Posted 28 November 2012 - 02:58 AM
why are you using fs.combine there? you should concatenate the strings

print(fs.combine(selectedsymbol, menuEintrage[x]))
|
V

print(selectedsymbol..menuEintrage[x])

lmfao I got ninja'd by the OP :D/> that's something new
Radioaktiv3 #4
Posted 28 November 2012 - 03:34 AM
i tryed it but double "." is also not usefull ,nothing changes
i am using nor –>


print(string.format("%s%s",selectedsymbol,menuEintrage[x]))

But thanks for ur help ;D