Basic concepts of OOP

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.
coffee
Party member
Posts: 1206
Joined: Wed Nov 02, 2011 9:07 pm

Re: Basic concepts of OOP

Post by coffee »

thelinx wrote:You just define enemy.add as
...
waraiotoko wrote: Agreed!

Code: Select all

function enemy:add(args)
	local enemy = {}
	enemy.race = args.race or "Human"
	enemy.hp = args.hp or "15"
	enemy.weapon = args.weapon or "Dagger"
	table.insert (enemies,enemy)
end
Thank you both. Always learning a bit more. Wasn't working till I realized that self (enemy in my case) shouldn't be there. I did knew "unpack" function(...) with then a local pack = {...} but nothing like this. Again I bow to you. :)
Post Reply

Who is online

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