So I was trying to do this little love program that saves coordinates to a variable but for some reason it isn't saveing them right.
Basically whenever you press the left mouse button the coordinates of the mouse's current position are saved to pointx pointy[a]
And once there are more than 3 coordinates for both X and Y there is an if code (well, it's a for inside an if) in the love.update(dt) that puts all the coordinates together in one variable called startxy and each coordinate is separated by a comma ",". It does that so that they can be used to draw a line like love.graphics.line(startxy)
This for code is not coded right but I can't seem to see what's wrong with it.
So can somebody please find what's wrong in this code also ignore all the cluster in there, I haven't properly cleaned it yet.
Thanks for reading and please help me on this
I can't seem to put together a variable
- Ranguna259
- Party member
- Posts: 911
- Joined: Tue Jun 18, 2013 10:58 pm
- Location: I'm right next to you
Re: I can't seem to put together a variable
You cannot store multiple return values in a single variable unless that variable is a table.
So this:
effectively just does the same as this:
as the second value has nowhere to go.
If you want to add values to a table, you need to put in a few table.insert calls.
Something like this:
should probably help you fix your problems.
So this:
Code: Select all
a = b, c
Code: Select all
a = b
If you want to add values to a table, you need to put in a few table.insert calls.
Something like this:
Code: Select all
table.insert( startx, pointx[1] )
table.insert( startx, pointy[1] )
- Ranguna259
- Party member
- Posts: 911
- Joined: Tue Jun 18, 2013 10:58 pm
- Location: I'm right next to you
Re: I can't seem to put together a variable
Yep that did the job, thanks manPlu wrote:You cannot store multiple return values in a single variable unless that variable is a table.
So this:effectively just does the same as this:Code: Select all
a = b, c
as the second value has nowhere to go.Code: Select all
a = b
If you want to add values to a table, you need to put in a few table.insert calls.
Something like this:should probably help you fix your problems.Code: Select all
table.insert( startx, pointx[1] ) table.insert( startx, pointy[1] )
You can check how it came out.
Once again, thanks
Who is online
Users browsing this forum: Bing [Bot] and 3 guests