Yeah I know that, I just assumed that 'self' would be automatically returned, like in Python
Search found 3 matches
- Sat Sep 21, 2024 9:42 am
- Forum: Support and Development
- Topic: [SOLVED] Error: attempt to index a nil value
- Replies: 4
- Views: 9664
Re: [SOLVED] Error: attempt to index a nil value
- Sat Sep 21, 2024 8:17 am
- Forum: Support and Development
- Topic: [SOLVED] Error: attempt to index a nil value
- Replies: 4
- Views: 9664
Re: Error: attempt to index a nil value
Hello, welcome to the forums. You're using the return value from Player.new() to set the variable `player`, yet you've forgetting to return a value within Player.new(). Simply add `return self` at the end of the function. Ah OK, I'm still not fully used to "classes" in Lua haha. Thanks fo...
- Fri Sep 20, 2024 9:48 pm
- Forum: Support and Development
- Topic: [SOLVED] Error: attempt to index a nil value
- Replies: 4
- Views: 9664
[SOLVED] Error: attempt to index a nil value
Hello. I'm taking my first steps into using LÖVE and I'm running into an issue that I can't quite identify. Here's my main.lua: Player = { pos = {0, 0}, speed = 0 } function Player.new(pos, speed) local self = setmetatable({}, Player) self.pos = pos or {0, 0} self.speed = speed or 300 end function l...