Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- File to store the count of broken snow blocks
- local snowCountFile = "snow_count.txt"
- -- Function to read the snow count from the file
- local function readSnowCount()
- if fs.exists(snowCountFile) then
- local file = fs.open(snowCountFile, "r")
- local count = tonumber(file.readLine())
- file.close()
- return count or 0
- else
- return 0
- end
- end
- -- Function to write the snow count to the file
- local function writeSnowCount(count)
- local file = fs.open(snowCountFile, "w")
- file.writeLine(tostring(count))
- file.close()
- end
- -- Initialize the count of broken snow blocks from the file
- local snowCount = readSnowCount()
- -- Function to check if the block in front is snow and break it if so
- local function checkAndBreakSnow()
- -- Get the block details in front of the turtle
- local success, data = turtle.inspect()
- if success and data.name == "minecraft:snow" then
- -- Break the block in front
- turtle.dig()
- -- Increment the snow block count
- snowCount = snowCount + 1
- -- Write the updated count to the file
- writeSnowCount(snowCount)
- -- Display the count on the screen
- term.clear()
- term.setCursorPos(1, 1)
- print("Snow blocks broken:")
- term.setCursorPos(1, 2)
- print(snowCount)
- end
- end
- -- Main loop to keep checking and breaking snow blocks
- while true do
- checkAndBreakSnow()
- -- Wait a short period before checking again
- sleep(0.5)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement