66 posts
Location
Minecraft world
Posted 12 June 2017 - 08:30 PM
Hello so i'm trying to make my os better by including tables but i came across a problem i couldn't fix
so what it loads everything prints normally but restart button is the only thing that works when i click shutdown it dosen't do anything when it should shutdown
code
function dropmenu1()
local menu1= {
["----------"] = {tcol = "green"; x = 1; xx = 11; y = 18; cmd = function() end};
[" Restart "] = {tcol = "green"; x = 1; xx = 11; y = 15; cmd = function() os.reboot() end};
[" Shutdown "] = {tcol = "green"; x = 1; xx = 11; y = 16; cmd = function() os.shutdown() end};
--[" Restart "] = {tcol = "green"; x = 1; xx = 11; y = 15; cmd = function() os.reboot() end};
["----------"] = {tcol = "green"; x = 1; xx = 11; y = 14};
[" Start "] = {tcol = "green"; x = 1; xx = 11; y = 13};
}
for v,k in pairs(menu1) do
term.setCursorPos(k.x, k.y)
print(v)
end
for k,v in pairs(menu1) do
e = {os.pullEvent()}
if e[1] == "mouse_click" then
if e[2] == 1 then
if e[3] >= v.x and e[3] <= v.xx and e[4] == v.y then
v.cmd()
else slc = 1
--drawdesk()
end
end
end
end
end
dropmenu1()
can any one see anything wrong with it?
Thx
Edited on 14 June 2017 - 04:53 AM
3057 posts
Location
United States of America
Posted 12 June 2017 - 10:19 PM
I copy-pasted that code into CC and both buttons work. So I'm a bit confused.
66 posts
Location
Minecraft world
Posted 13 June 2017 - 03:51 PM
I copy-pasted that code into CC and both buttons work. So I'm a bit confused.
Wow well shutdown dosen't work for me
Ohh well nvm i know why now its because i have to click outside shutdown.. idk why
Do any one know why i have to click outside the text?
3057 posts
Location
United States of America
Posted 13 June 2017 - 04:02 PM
Are you running this on a monitor? There is a
bug which may be the culprit.
66 posts
Location
Minecraft world
Posted 13 June 2017 - 04:10 PM
No i'm not i'm using the normal terminal btw can you click directly on the text for me i have too click outside of it
Are you running this on a monitor? There is a
bug which may be the culprit.
No i'm not i'm using the normal terminal btw can you click directly on the text for me i have too click outside of it
3057 posts
Location
United States of America
Posted 13 June 2017 - 05:22 PM
I was actually able to reproduce the problem just now. It seems resizing the minecraft window does something screwey. I'm using the latest version of CC so that may be the problem.
It's not a problem with your script though. This is a computercraft bug which you have no control over.
66 posts
Location
Minecraft world
Posted 13 June 2017 - 05:24 PM
I was actually able to reproduce the problem just now. It seems resizing the minecraft window does something screwey. I'm using the latest version of CC so that may be the problem.
It's not a problem with your script though. This is a computercraft bug which you have no control over.
ohh well that weird. Because i tried
another script that works just the same and it works fine
66 posts
Location
Minecraft world
Posted 13 June 2017 - 06:27 PM
and if so is there an solution?
I was actually able to reproduce the problem just now. It seems resizing the minecraft window does something screwey. I'm using the latest version of CC so that may be the problem.
It's not a problem with your script though. This is a computercraft bug which you have no control over.
3057 posts
Location
United States of America
Posted 13 June 2017 - 09:21 PM
Move the event pulling out of the for loop. I completely missed that it was in there because your indentation is screwy, sorry.
66 posts
Location
Minecraft world
Posted 14 June 2017 - 06:53 AM
Move the event pulling out of the for loop. I completely missed that it was in there because your indentation is screwy, sorry.
Thank you so much!! it works now!
:D/>