1 posts
Posted 28 February 2016 - 05:23 PM
i'm new to this and can't seem to understand what does this mean?
the code is very simple
local event, x, y = os.pullEvent("mouse_click")
if event == "mouse_click" then
print("Event: "..event)
print("X: "..x)
print("Y: "..y)
end
and it only happens when i have a third variable like "y" because i tried with local event and x and it worked fine
2679 posts
Location
You will never find me, muhahahahahaha
Posted 28 February 2016 - 06:15 PM
1. You forgot the button: event, button, x, y
2. A small modification I make to avoid error like this:
local event, button, x, y = os.pullEvent("mouse_click")
if event == "mouse_click" then
print("Event: "..event)
print("X: ", x)
print("Y: ", y)
end
3. Event will always be "mouse_click" so no need to check.
4. Also, x and y should be numbers, not strings and you cannot concat strings with numbers.
1080 posts
Location
In the Matrix
Posted 28 February 2016 - 06:53 PM
Well yes you can, and his error wasn't "attempt to concatenate string and number" it was "attempt to concatenate string and nil" which means for some reason the 3rd return value for his os.pullEvent call returned nil.
Also, yes, that is the order of the return values, in his case, his x was button, and y was x. However for whatever reason his x coordinate was nil.
Before it errored Pineappl, what did it print? It should of printed something like
mouse_click
1
Edited on 28 February 2016 - 05:55 PM
212 posts
Location
Somewhere in this dimension... I think.
Posted 28 February 2016 - 07:49 PM
Numbers and strings are interchangable except if it is a string with letters, only then is it interchangable in one direction. (To string) There are also other interchangable things. Numerical arrays and named arrays for example.
1140 posts
Location
Kaunas, Lithuania
Posted 28 February 2016 - 08:44 PM
Numerical arrays and named arrays for example.
In Lua there are no arrays, there are only tables.
212 posts
Location
Somewhere in this dimension... I think.
Posted 28 February 2016 - 08:58 PM
Array = Table which is essentially what I was getting at.