Posted 11 January 2013 - 11:44 PM
hello all… it has come that time again that I need some fresh eyes having a look to see what I'm doing wrong…
I'm attempting to make my Extended String Library into an object and am running into problems.
thought id start it off easy with basic code, but it doesn't even work…
string library code:
how its being called:
I get the error "tester:3: attempt to call nil"
if anyone can see my mistake that would be great :)/>
I'm attempting to make my Extended String Library into an object and am running into problems.
thought id start it off easy with basic code, but it doesn't even work…
string library code:
str = {}
str.__index = str
str.__tostring = function( self ) return self.data end
function str.new( d )
local stringObject = { data = ( d and d or "" ) }
setmetatable( stringObject, str )
return stringObject
end
how its being called:
os.loadAPI( "/Extended-String-Library/dirty/str")
local s = str:new()
print( tostring( s ) )
I get the error "tester:3: attempt to call nil"
if anyone can see my mistake that would be great :)/>