Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Tree Analyzer
- local inventory = peripheral.wrap("back");
- function getAmount()
- return inventory.getItemDetail(2).count;
- end
- local count = 1;
- local oldAmount = getAmount();
- local newAmount = 0;
- local sum = 0;
- local average = 0;
- function parseTime(timeInSeconds)
- if timeInSeconds < 60 then
- if timeInSeconds < 10 then return 0 .. timeInSeconds;
- else return timeInSeconds;
- end
- elseif timeInSeconds < 3600 then
- local minutes = math.floor(timeInSeconds / 60);
- local seconds = timeInSeconds % 60;
- if minutes < 10 then minutes = 0 .. minutes end
- if seconds < 10 then seconds = 0 .. seconds end
- return minutes .. ":" .. seconds;
- elseif timeInSeconds < 86400 then
- local hours = math.floor((timeInSeconds / 60) / 60)
- local minutes = math.floor((timeInSeconds / 60) % 60);
- local seconds = timeInSeconds % 60;
- if hours < 10 then hours = 0 .. hours end
- if minutes < 10 then minutes = 0 .. minutes end
- if seconds < 10 then seconds = 0 .. seconds end
- return hours .. ":" .. minutes .. ":" .. seconds;
- else
- local seconds = timeInSeconds % 60;
- local minutes = math.floor((timeInSeconds / 60) % 60);
- local hours = math.floor(((timeInSeconds / 60) / 60) % 24)
- local days = math.floor(((timeInSeconds / 60) / 60) / 24)
- if days < 10 then days = 0 .. days end
- if hours < 10 then hours = 0 .. hours end
- if minutes < 10 then minutes = 0 .. minutes end
- if seconds < 10 then seconds = 0 .. seconds end
- return days .. ":" .. hours .. ":" .. minutes .. ":" .. seconds;
- end
- end
- term.clear();
- term.setCursorPos(1,1);
- term.write("Uptime: ");
- term.setCursorPos(1,2);
- term.write("Average Increase Per Second: ")
- term.setCursorPos(1,3);
- term.write("Amount Of Wood: ");
- function updateScreen()
- term.setCursorPos(9, 1);
- term.write(parseTime(count));
- term.setCursorPos(30, 2);
- term.write(math.floor(average));
- term.setCursorPos(17,3);
- term.write(getAmount());
- end
- while true do
- local dif = getAmount() - oldAmount;
- oldAmount = getAmount();
- sum = sum + dif;
- average = sum / count;
- sleep(1);
- updateScreen();
- count = count + 1;
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement