If you're having trouble with your Playdate device please contact support directly via the form at https://help.play.date/
Tips on what to include in your question:
- Have a clear title
- Provide what platform you're using the SDK on (Mac, Windows, or Linux)
- What do you need help with? Describe your issue and include screenshots or videos if possible.
- What have you tried so far? You may find other similar threads to this issue by searching SDK Get Help - Playdate Developer Forum (click the search button at the top right from Get Help).
I’m on windows, using lua to code for the SDK. It’s been a bit and I’m trying to get my head wrapped around classes in lua. I have a file called Data/personData
---@class personData
---@field age integer
---@field race string
class("personData")
function personData:init()
self.age = 0
self.race = ""
end
Now, in my main I’m doing:
import "CoreLibs/object"
import "CoreLibs/graphics"
import "CoreLibs/sprites"
import "CoreLibs/timer"
import("data/personData")
-- import "./data/personData"
-- import "inputs/"
local function initalize()
personData()--[[@as personData]]
personInstance.age = 55
end
initalize()
function playdate.update()
gfx.sprite.update()
pd.timer.updateTimers()
end
When I try to run it shows an error:
Update error: data/personData.lua:7: attempt to index a nil value (global 'personData')
stack traceback:
data/personData.lua:7: in main chunk
stack traceback:
[C]: in function 'import'
main.lua:6: in main chunk
Which doesn’t make any sense to me. What am I missing? I’ve tried all sorts of ways to get it to work, like using returns and adding it global variable. It’s hurting my brain O…o
Could anyone sine some light on the piece I’m missing?