Array Argument Not Working

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
nmimagine
Prole
Posts: 2
Joined: Thu Jul 31, 2014 4:36 am
Location: Jakarta, Indonesia

Array Argument Not Working

Post by nmimagine »

So I'm making a GUI library for my game, a button class. Here's the snippet of my codes :

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
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....

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}
				})
But those codes result an error :
Attempt to index local 'opt' (a nil value)
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 :
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....
Attachments
Sang Saka.love
Oh yeah, here's my attachment. It's a little game I working on to celebrate my country's independence day. Just in case you want to now. The UI is in Indonesian, but the code is in English.....
(378.3 KiB) Downloaded 100 times
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Array Argument Not Working

Post by bartbes »

When a new object gets created with SECS, using the new method, that already calls init for you. So instead of calling new without arguments, and then calling init with arguments, just call new with arguments and you're set.
nmimagine
Prole
Posts: 2
Joined: Thu Jul 31, 2014 4:36 am
Location: Jakarta, Indonesia

Re: Array Argument Not Working

Post by nmimagine »

MANY THANKS!!! :ultraglee: :ultraglee: :ultraglee: :ultraglee:
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 6 guests