Code: Select all
global = global or {}
global.mt = global.mt or {}
global.mt.array_simple = {}
global.mt.array_simple.__newindex = function()end
global.mt.array_simple.__index = global.mt.array_simple
function global.mt.array_simple:add(element)
self.length = self.length +1
rawset(self, self.length, element)
end
global.new = global.new or {}
global.new.array_simple = function()
local self = {}
self.length = 0
setmetatable(self, global.mt.array_simple)
return self
end
Code: Select all
script.on_event(defines.events.on_tick, function(event)
if not flag
then
flag = true
local cont = global.new.array_simple()
cont:add({})--this line causes error in multiplayer. Error is like, add is nil.
end
end)