89 posts
Location
USA
Posted 14 February 2013 - 10:47 AM
ive made a lock system useing the mouse to select thing but when i try tried putting the os.pullEvent = os.pullEventRaw and tried to bypass it it came up with an error and stopped the program and showed this error
startup:3: attempt to concatenate string and nill
heres the code
http://pastebin.com/wYSYLknm
8543 posts
Posted 14 February 2013 - 11:16 AM
Split into new topic.
It probably threw a terminate event, so X and Y would have been nil. You'll need to handle that case appropriately.
5 posts
Posted 14 February 2013 - 11:28 AM
All you would need to do is add a value for x and y, it doesn't need to be anything in particular just any value.
Ex.
x = 1
y = 1
Now if g() was only called on a mouse click event this wouldn't be an issue, but rather when it goes through without a mouse click x = nil and y = nil, which is why you get the startup:3: attempt to concatenate string and nill
758 posts
Location
Budapest, Hungary
Posted 15 February 2013 - 02:23 AM
I'm not sure what's wrong with G(), but the only way to get out of a pullEvent() with a "mouse_click" filter on a non-advanced computer is a "terminate" event, and that gives nil as the second and the third value. (Yes, I know that ChunLing's already mentioned it.)
But here are things you might want to change:
DrawBackground()
Spoiler
function DrawBackground()
term.setCursorPos(1,1)
local termw, termh = term.getSize() -- I know that 51 * 19 is 969, but for example I'm using CC with a terminal size of 80 * 25
-- you can delete the line above if you put it at the beginning of the program
term.setBackgroundColor(colors.blue) -- it's enough to set the color once
term.setTextColor(colors.blue)
for i = 1, termw * termh do
write("G")
end
end
instead of
function DrawBackground()
term.setCursorPos(1,1)
for i = 1,969 do
term.setBackgroundColor(colors.blue)
term.setTextColor(colors.blue)
write("G")
end
end
Login screen header
Spoiler
This
local termw, termh = term.getSize() -- I know that 51 * 19 is 969, but for example I'm using CC with a terminal size of 80 * 25
-- you can delete the line above if you put it at the beginning of the program
local textLeft = "Login"
local textRight = "SteamPunkOS"
print(textLeft..string.rep(" ", termw - #textLeft - #textRight)..textRight)
is more portable then
print("Login SteamPunkOS")
pullEventRaw
Spoiler
I know it's commented, but it's safer to have a version of pullEvent that can be terminated then to not have. So back it up.
os.pullEventTerminatable = os.pullEvent
os.pullEvent = os.pullEventRaw
2217 posts
Location
3232235883
Posted 15 February 2013 - 02:24 AM
-snippy derp-
7 posts
Posted 15 February 2013 - 06:42 AM
iirc local os.pullEvent=os.pullEventRaw gives a syntax error…
8543 posts
Posted 15 February 2013 - 07:54 AM
iirc local os.pullEvent=os.pullEventRaw gives a syntax error…
You recall incorrectly.
7 posts
Posted 15 February 2013 - 08:25 AM
iirc local os.pullEvent=os.pullEventRaw gives a syntax error…
You recall incorrectly.
Then my computers are lieing to me ;p
local os.pullEvent = os.pullEventRaw
bios:338: [string "lol"]:1: unexpected symbol
8543 posts
Posted 15 February 2013 - 08:52 AM
Oh, I may have misread and not noticed the local. It will probably work a bit better without it. ;)/>
89 posts
Location
USA
Posted 15 February 2013 - 11:01 AM
ok i've added values to X and Y but now my mouse doesnt work