Removing references to self because real machines have no references to self

Improving working/not working behaviour on MockMultiblock
This commit is contained in:
Gabriel Moreira Minossi 2021-01-17 23:36:25 -03:00
parent 54b99310f1
commit de5daf49bd

View File

@ -8,34 +8,35 @@ local MockMultiBlock =
MockSingleBlock, MockSingleBlock,
{ {
name = "MockMultiBlock", name = "MockMultiBlock",
progress = 0, isBroken = false
maxProgress = 0,
} }
) )
function MockMultiBlock:getSensorInformation() function MockMultiBlock.getSensorInformation()
self.progress = self.progress + 1 MockMultiBlock.workProgress = MockMultiBlock.workProgress + 1
if self.progress > self.maxProgress then if MockMultiBlock.workProgress > MockMultiBlock.workMaxProgress then
self.maxProgress = math.random(500) MockMultiBlock.workProgress = 0
self.progress = 0
end end
self.isBroken = self.isBroken or math.random(100000) > 99999 if MockMultiBlock.workAllowed and not MockMultiBlock.isBroken and math.random(1000) > 999 then
MockMultiBlock.workMaxProgress = math.random(500)
end
MockMultiBlock.isBroken = MockMultiBlock.isBroken or math.random(100000) > 99999
return { return {
"Progress: §a" .. self.progress .. "§r s / §e" .. self.maxProgress .. "§r s", "Progress: §a" .. MockMultiBlock.workProgress .. "§r s / §e" .. MockMultiBlock.workMaxProgress .. "§r s",
"Stored Energy: §a1000§r EU / §e1000§r EU", "Stored Energy: §a1000§r EU / §e1000§r EU",
"Probably uses: §c4§r EU/t", "Probably uses: §c4§r EU/t",
"Max Energy Income: §e128§r EU/t(x2A) Tier: §eMV§r", "Max Energy Income: §e128§r EU/t(x2A) Tier: §eMV§r",
"Problems: §c" .. self.isBroken and 1 or 0 .. "§r Efficiency: §e100.0§r %", "Problems: §c" .. (MockMultiBlock.isBroken and 1 or 0) .. "§r Efficiency: §e100.0§r %",
"Pollution reduced to: §a0§r %", "Pollution reduced to: §a0§r %",
n = 6 n = 6
} }
end end
function MockMultiBlock:setWorkAllowed(allow) function MockMultiBlock.setWorkAllowed(allow)
if self.isBroken then if MockMultiBlock.isBroken then
self.isBroken = false MockMultiBlock.isBroken = false
end end
self.workAllowed = allow MockMultiBlock.workAllowed = allow
end end
return MockMultiBlock return MockMultiBlock