Hello everyone,
Assume I create a simple function that randomly generates a ball to be located on one of three floors. Like so:
balltable = {}
local function spawnball()
local i = math.random (3)
local ball = display.newImage("Ball.PNG")
allballs[#allBalls+1] = ball
ball.floor = i
ball.x = 100 x i
end
How would I go about writing a function that checks whether balltable contains a ball with “ball.floor” having a certain value. For example, lets say there are three buttons that correspond to each floor and the user must press a button for a floor that has a ball on it. How would the function associated with the button check whether there is a value in balltable with ball.floor = 3
I hope my hypothetical example is clear enough. I’m trying to learn how to search values in tables. [import]uid: 78150 topic_id: 20894 reply_id: 320894[/import]