Array Argument Not Working
Posted: Thu Jul 31, 2014 5:07 am
So I'm making a GUI library for my game, a button class. Here's the snippet of my codes :
Yeah, as you see, I used Bart van Strien's "Simple Educative Class System", but I think that's not the problem...
And for the implementation....
But those codes result an error :
http://www.lua.org/pil/5.3.html
And also from this forum, the closest one, but I think it's different from my case:
viewtopic.php?f=4&t=9187
I have no idea what to do, and where I should ask this question (Love2d forum, or another programming forum like stackoverflow). But here's my question, I need your help....
Code: Select all
button = class:new()
function button:init(opt)
self.x = opt.x
self.y = opt.y
self.command = opt.command
self.mode = opt.mode
-- And so on
end
And for the implementation....
Code: Select all
playbtn = button:new()
playbtn:init({
x = 525,
y = 400,
command = startgame,
mode = "text",
text = "Play",
font = fonts.mutlu,
color1 = {153,153,153},
color2 = {255,255,255}
})
I've trying a lot of things, but none of them solve the problem. One of them is from LUA documentation, here's the link :Attempt to index local 'opt' (a nil value)
http://www.lua.org/pil/5.3.html
And also from this forum, the closest one, but I think it's different from my case:
viewtopic.php?f=4&t=9187
I have no idea what to do, and where I should ask this question (Love2d forum, or another programming forum like stackoverflow). But here's my question, I need your help....