A very easy question regarding .something() functions.

Hello!

How do I make a function like 

something.isTrue()

and it returns the value true.

Sorry for creating a new topic for such an easy question that has probably been answered, but I have no idea what this is called and have been searching for 30 minutes with no result.

Assuming that the object “something” already exists (and not knowing what you want to test to see is true or not:

function something.isTrue()      if true then          return true      else          return false      end end

or if you want it to be able to check itself (object oriented thinking)

function something:isTrue() -- colon operator says to make self = the object in question if self.somevalue == true then return true else return false end end

might work better for you.

Rob

Thanks, Rob

I want it to be object oriented, does it matter what “something” is in 

function something:canSmoke()

You can make up whatever function you want and you can do it to any table/object.

Assuming that the object “something” already exists (and not knowing what you want to test to see is true or not:

function something.isTrue()      if true then          return true      else          return false      end end

or if you want it to be able to check itself (object oriented thinking)

function something:isTrue() -- colon operator says to make self = the object in question if self.somevalue == true then return true else return false end end

might work better for you.

Rob

Thanks, Rob

I want it to be object oriented, does it matter what “something” is in 

function something:canSmoke()

You can make up whatever function you want and you can do it to any table/object.