More class help

How would you do something like
If self.x<0 then
Points:CPU()
End

What exactly are you asking? Are you trying to call a functions if the variable self.x < 0? Also, what class is the self.x inside of?
As a side note- The word ‘end’ should not be capitalized

Yes how would you call a class function in a different class?

Well, you can do either.

pts = Pts()
pts.cpu(). -- multiple instance of the pts

– or –

Pts:CPU()
 -- called upon the static class instance. Use if you have something like self.value declared in init(),

As @edat said, both are valid, so it comes down to what you are trying to accomplish.

I’m having trouble understanding sorry?

Ok let’s say in class Class1 self.x = 0 and I wanted to check if self.x is bigger than 0 in class Class2?

This is most likely wrong, but its the only way i could think of


Class1 = class()
function Class1:init()
self.x = math.random(1,10)
end
function Class1:setup
parameter.watch("self.x")

Class2 = class()
function Class2:init()
if self.x > 0 then
print("Number"..self.x)
If self.x < 0 then
end

Like i said, its most likely wrong, but hey, im learning

Yea that doesn’t work I’m afraid

Didnt think so