Jump to content

Recommended Posts

I'm trying to wrap my head around some of these declarations and functions. I will put out the two that are confusing me the most:

 

local StalkerBrain = Class(Brain, function(self, inst)
    Brain._ctor(self, inst)
    self.abilityname = nil
    self.abilitydata = nil
    self.snaretargets = nil
    self.hasfeast = nil
    self.hasminions = nil
    self.checkminionstime = nil
    self.wantstospikes = nil
end)

 

I'm getting confused by the first bit to be honest. What's a class? Is it like a struct?

 

local function IsDefensive(self)
    return self.inst.components.health.currenthealth < TUNING.STALKER_ATRIUM_PHASE2_HEALTH
end

 

I'm getting confused by a small part of the return statement. Is self a lua keyword or was it a created one? Same with inst. What exactly do self and inst refer to?

 

Also, any resources that would be useful to understand lua better would be appreciated.

@tacticalweapon1 

Yes, class is like a struct. I'm not experienced with C, but a quick google search seems to confirm my thoughts on what a struct is.

It's not really a keyword. It's mostly used in metatables to reference the object. However, it's different in that it acts like a variable. 

 

http://www.lua.org/manual/5.1/ This is quite helpful.
Most of the game's code revolves around using meta tables, so I suggest you make sure you understand that section.

Edited by penguin0616
  • Like 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...