0 Members and 6 Guests are viewing this topic.
"welcome to the world of computers, where everything seems to be based on random number generators"
local print = graydraw.printclass = function(prototype) local derived = {} local derivedMT = { __index = prototype, __call = function(proto, ...) local instance = {} local instanceMT = { __index = derived, __call = function() return nil, "ERROR: Attempt to invoke an instance of a class" end, } setmetatable(instance, instanceMT) if instance.init then instance:init(...) end return instance end, } setmetatable(derived, derivedMT) return derivedendcar = class()function car: init(power, type, lights, etc) self.power = power self.type = type self.lights = lights*2 self.options = etcendjeep = car(60, "4x4", 12, {air-conditioning = False, trailer-hook = True})if jeep.options.trailer-hook then print("The jeep can have a trailer")else print("No trailer for you :(")end
[string 'experiment.lua']:35: '}' expected near '='
local print = graydraw.printclass = function(prototype) local derived = {} local derivedMT = { __index = prototype, __call = function(proto, ...) local instance = {} local instanceMT = { __index = derived, __call = function() return nil, "ERROR: Attempt to invoke an instance of a class" end, } setmetatable(instance, instanceMT) if instance.init then instance:init(...) end return instance end, } setmetatable(derived, derivedMT) return derivedendcar = class()function car: init(power, type, lights, etc) self.power = power self.type = type self.lights = lights*2 self.options = etcendjeep = car(60, "4x4", 12, {airconditioning = false,trailerhook = true})if jeep.trailerhook then print("The jeep can have a trailer")else print("No trailer for you :(")end
[string 'experiment.lua']:22: Attempt to call global 'setmetatable', a nil value
well, flyingfisch, don't feel like making one too? could be very useful..
i asked myself that question too, most people say C++, dunno why, but it's true..btw: i don't know the difference..