As a newbie, I’m experimenting with dealing a deck of cards from left to right. All usually works well, but randomly the following error appears, any help would be appreciated:
Runtime error
c:\dev\corona\vpu\job.lua:216: attempt to concatenate local ‘nslot’ (a n
il value)
stack traceback:
[C]: ?
c:\dev\corona\vpu\job.lua:216: in function ‘_listener’
?: in function <?:514>
?: in function <?:215>
Here is the code:
function initialDeal()
function showCard(event)
audio.play(cardsound);
local nindex = event.source.params[1];
local nslot = event.source.params[2];
local x = bfv[nindex].x;
local y = bfv[nindex].y;
bfv[nindex] = display.newImage("images/"..nslot..".png");
bfv[nindex]:scale(1.2,1.2);
bfv[nindex].x = x;
bfv[nindex].y = y;
timer.cancel(cardtimers[nindex]);
end
local seed = os.time();
math.randomseed(seed);
cards = cardfunctions.shuffleDeck();
for i=1, 5 do
cardtimers[i] = timer.performWithDelay(200\*i,showCard);
local params = {}
params[1] = i;
local cardno = math.random(1,54);
while (cards[cardno] == -1) do
cardno = math.random(1,54);
end
params[2] = cards[cardno];
cards[cardno] = -1;
cardtimers[i].params = params;
end
end
[import]uid: 66769 topic_id: 25394 reply_id: 325394[/import]
