So I'm playing around with the Grid-Locked Player Tutorial from the LOVE2d wiki, and I come across this error when I try to run it. "attempt to index global 'player' (a nil value)"
Full Code: My Code
Here's the specific code snippet that was causing the problem.
if enemyFOV <= player.grid_x then
shoot()
end
I've already looked at other similar questions on this site, and none seemed to apply to my problem. Except for one that had the solution of using
return
after the shoot() function.
So Stack Overflow, my question is, What should I do to fix this?
Etan Reisner had the correct answer here. The code snippet that is giving you the error resides outside of any function. If you move the offending code inside of love.update(), your problem should be solved.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.