It looks like you're new here. If you want to get involved, click one of these buttons!
My program includes classes for Person, Queue, and Elevator objects. The Elevator class includes a method for moving an elevator up or down:
function Elevator:move() if self.y > self.targety then self.y = self.y - 1 if elevatorQ:numberIn() >= 1 then for i = 1, elevatorQ:numberIn() do elevatorQ[i] :moveDown() end end end if self.y < self.targety then self.y = self.y + 1 if elevatorQ:numberIn() >= 1 then for i = 1, elevatorQ:numberIn() do elevatorQ[i] :moveUp() <--------- crashes here end end end end
Person objects have moveUp and moveDown methods, and I have a global Queue object called elevatorQ that contains references to Person objects that must move with the Elevator. When the code above runs, it crashes with the message "Attempt to index nil value" where I have indicated. elevator[i]  is the field that contains a reference to a Person. Can someone please tell me what I'm doing wrong here?