I am trying to set a color, but it does not work.
--stats.lua local bot = {} local bot\_mt = {\_\_index = bot} local function start(self) --do something with this bot end local function stop(self) --do something with this bot end function bot:new(x, y, color, height, width) local newBot = {} newBot.x, newBot.y = x,y newBot.height, newBot.width, newBot.fill = height, width, color --declare functions for bot newBot.start = start newBot.stop = stop return setmetatable( newBot, bot\_mt ) end return bot --main.lua local bot = require "stats" local bots = {} for i = 1, 20 do local aNewBot = bot:new(i, i, {1,0,0,0.5}, 10, 10) bots[#bots+1] = aNewBot print(aNewBot.x, aNewBot.y) print(aNewBot.fill) end
This is what I get printed (but 10 more times):
1 1 table: 0x7ff73bf67bc0 2 2 table: 0x7ff73bf67d10 3 3 table: 0x7ff73bf67f80 4 4 table: 0x7ff73bf68230 5 5 table: 0x7ff73bf68350 6 6 table: 0x7ff7397a8040 7 7 table: 0x7ff7397a8340 8 8 table: 0x7ff7397a85d0 9 9 table: 0x7ff7397a8860 10 10 table: 0x7ff7397a8a90
How do I fix this?