IceG4merBR 0 Posted May 8, 2018 Share Posted May 8, 2018 Got this error, but i have no idea how to fix it, need some help!. Here is the code. local component = require("component") local term = require("term") local gpu = component.gpu local cube = component.basic_energy_cube local event = require("event") local colors = { black = 0x000000, red = 0xC14141} gpu.setBackground(colors.black) term.clear() local infos = {} cube["stats"] = {} function setInfos() infos["stored"] = { x = 3, y = 2, weight = 73, height = 1, title = "STORED ENERGY : ", unit = " RF"} infos["capacity"] = { x = 3, y = 4, weight = 73, height = 1, title = "BATTERY CAPACITY : ", unit = " RF"} end function printInfos(infoName) local maxLenght = 15 local i = infos[infoName] gpu.set(i.x, i.y, i.title .. cube.stats[infoName] .. i.unit) end function updateCubeStats() cube.stats["stored"] = cube.getEnergyStored end function startup() updateCubeStats() setInfos() printInfos() end startup() repeat updateCubeStats() until event.pull(0.1) == "interrupted" Quote Link to post Share on other sites
0 Gorzoid 10 Posted May 8, 2018 Share Posted May 8, 2018 infoName isnt assigned, you forgot to call printInfos with a string, something like printInfos("stored") Quote Link to post Share on other sites
0 IceG4merBR 0 Posted May 8, 2018 Author Share Posted May 8, 2018 I got this error now. Only changed the printInfos() in startup() to printInfos("stored") local component = require("component") local term = require("term") local gpu = component.gpu local cube = component.basic_energy_cube local event = require("event") local colors = { black = 0x000000, red = 0xC14141} gpu.setBackground(colors.black) term.clear() local infos = {} cube["stats"] = {} function setInfos() infos["stored"] = { x = 3, y = 2, weight = 73, height = 1, title = "STORED ENERGY : ", unit = " RF"} infos["capacity"] = { x = 3, y = 4, weight = 73, height = 1, title = "BATTERY CAPACITY : ", unit = " RF"} end function printInfos(infoName) local maxLenght = 15 local i = infos[infoName] gpu.set(i.x, i.y, i.title .. cube.stats[infoName] .. i.unit) end function updateCubeStats() cube.stats["stored"] = cube.getEnergyStored end function startup() updateCubeStats() setInfos() printInfos("stored") end startup() repeat updateCubeStats() until event.pull(0.1) == "interrupted" Quote Link to post Share on other sites
0 Molinko 43 Posted May 9, 2018 Share Posted May 9, 2018 I believe your error is coming from updateCubeStats(). cube.stats.stored = cube.getEnergyStored() You're missing parentheses. IceG4merBR 1 Quote Link to post Share on other sites
Got this error, but i have no idea how to fix it, need some help!.
Here is the code.
Link to post
Share on other sites