View Single Post
04/29/14, 11:32 AM   #8
Iyanga
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 183
Originally Posted by Sideshow View Post
Hello

I'm a programmer with a couple of years C# and JavaScript experience and I'm wondering how to perceive the lua environment in an object oriented context, in ESO.
Not at all, because LUA in itself is not object oriented.

What is done is that objects are mimicked, very much like you can do this in ANSI C.

You can't have an object with methods in ANSI C, but you can have a structure with function pointers.
You can't have an object with methods in LUA, but you can have a table with variables and functions are valid variable contents already in LUA. The rest is how to name and group tables and variables consistently, to make it feel like object orientation.

Okay, one trick is there that is...when you have a table and you want to lookup the content of table (a.ka. call a method of the object) you can rewrite the object instance to also look somewhere else for a table entry and if this somewhere else is the Singleton table, which you used as template to create a new table from, it feels like inheritance, because the function of the "master table" is called, if your instance didn't implement it.

So yes, it is a big sequential script. Of course, in ESO it's also a big loop and state machine, so it doesn't feel that sequential. That variables have a scope does not make it less sequential. And as LUA defines every variable as global by default, you have local to limit the scope. Unlike JavaScript, where a var inside a function is already under local scope. In LUA it is global.
  Reply With Quote