first Attempt at OOP... [resolved] :)

ok so I am referring to Beebes great tutorial on Classes that you can find here

http://blog.anscamobile.com/2011/09/tutorial-modular-classes-in-corona/
So as a test I tried to create my own file and I got an error that says this…

Runtime error
error loading module ‘wings’ from file ‘/var/folders/NS/NS3zjtx7HZS-a189GNQo1k+++TI/-Tmp-/TemporaryItems/465/wings.lua’:
…olders/NS/NS3zjtx7HZS-a189GNQo1k+++TI/-Tmp-/TemporaryItems/465/wings.lua:27: ‘(’ expected near ‘.’
stack traceback:
[C]: ?
[C]: ?
[C]: in function ‘require’
…ZS-a189GNQo1k+++TI/-Tmp-/TemporaryItems/465/main.lua:1: in main chunk
Runtime error: error loading module ‘wings’ from file ‘/var/folders/NS/NS3zjtx7HZS-a189GNQo1k+++TI/-Tmp-/TemporaryItems/465/wings.lua’:
…olders/NS/NS3zjtx7HZS-a189GNQo1k+++TI/-Tmp-/TemporaryItems/465/wings.lua:27: ‘(’ expected near ‘.’
stack traceback:
[C]: ?
[C]: ?
[C]: in function ‘require’
…ZS-a189GNQo1k+++TI/-Tmp-/TemporaryItems/465/main.lua:1: in main chunk
my wings.lua file looks like this

[lua]-------------------------------------------------

– wings.lua

– Attach wings to rocket ship


local wings = {}
local wings_mt = { __index = wings } – metatable


– PRIVATE FUNCTIONS

local function isWingsFixed( realYears ) – local; only visible in this module
return realYears * 7
end


– PUBLIC FUNCTIONS

local function wings.new (name, ageInYears)

local newWing = {
name = name or “Unnamed”,
age = ageInYears or 2
}

return setmetatable( newWing, wings_mt )
end


local function wings:repair()
print( self.name … " wings are repairing!." )
end


function wings:printFixed()
print( self.name … " is " … isWingsFixed( self.age ) … " wings have been repaired." )
end


return wings[/lua]

You can see its pretty much the same as the tutorial but replaced a few names to match what I have going on in my game… This is what I put in my main.lua file

[lua] local wings = require( “wings” )

local wings1 = wings.new( “redWing”, 3 )

wings1:printFixed()[/lua]

I thought that I had understood everything when did the example in my own set of files, but of course I ran into some problems when I added my own names and information in it… So if anyone can point out what I did wrong that would help me out GREATLY

Thanks [import]uid: 51459 topic_id: 17019 reply_id: 317019[/import]

I GOT IT… Didn’t mean to set some things to local…

Heres the fixed code if anybody wants to see the correct version of my wings.lua!!!
[lua]-------------------------------------------------

– wings.lua

– Attach wings to rocket ship


local wings = {}
local wings_mt = { __index = wings } – metatable


– PRIVATE FUNCTIONS

local function isWingsFixed( realYears ) – local; only visible in this module
return realYears * 5
end


– PUBLIC FUNCTIONS

function wings.new(name, ageInYears)

local newWing = {
name = name or “Unnamed”,
state = ageInYears or 100
}

return setmetatable( newWing, wings_mt )
end


function wings:repair()
print( self.name … " wings are repairing!." )
end


function wings:printFixed()
print( self.name … " is " … isWingsFixed( self.state ) … " wings have been repaired." )
end


return wings[/lua] [import]uid: 51459 topic_id: 17019 reply_id: 63877[/import]