Hi guys,
I've got some code here where I'm trying to illustrate a set of 5 cards; the last five played. The problem is that they're being displayed in reverse order:
http://imgur.com/AumA5MV
That image shows the start of a game, 4 cards played. The first card played is displayed fully, where as the last (latest) is displayed underneath. The actual ordering is fine, they're in place - just reversed.
http://codepad.org/ro6iZhOd
Cards being played are added to the pile with a normal table.insert, with no position specified; so they should just be adding the the end of the table, which means (to me at least) that the code should work. Can anyone point me in the right direction with this?
Help drawing images properly
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Help drawing images properly
Normally, yes, but you're looping in reverse order. Replace line 3 by:
And line 17 by:
Hope that helps.
By the way, we'd prefer it that you upload a .love when you have a problem in the future. That way we can see if our proposed solution actually works before replying.
Code: Select all
for i = #GLOBAL_VARS.CardPile-4, #GLOBAL_VARS.CardPile do
Code: Select all
for i =1, #GLOBAL_VARS.CardPile do
By the way, we'd prefer it that you upload a .love when you have a problem in the future. That way we can see if our proposed solution actually works before replying.
Help us help you: attach a .love.
Re: Help drawing images properly
Thanks for the help! And I'll remember that in the future, thanks for the info.
Re: Help drawing images properly
I have to ask, what is the deal with the GLOBAL_VARS table? It sounds suspiciously like _G, the "contents" of which can be accessed globally, since they're globals.
In Lua, pretty much everything you declare is global unless you specify otherwise (obvious exceptions are function parameters).
Code: Select all
someFunc = function()
x = 1
end
someFunc()
print(x) -- 1
print(_G.x) -- 1
Do you recognise when the world won't stop for you? Or when the days don't care what you've got to do? When the weight's too tough to lift up, what do you? Don't let them choose for you, that's on you.
Who is online
Users browsing this forum: No registered users and 1 guest