举例:
Unit.lua
local Unit = {};Unit.Name = function (u) print(u.name);endreturn Unit;
Monster.lua
local Unit = require "Unit";local Monster = {};Monster.Name = Unit.Name;return Monster;
run.lua
local Monster = require "Monster"m = {};m.name = "test";Monster.Name(m);
这里实现的类要做到数据和逻辑分离,好处有很多