ComputerCraft Archive

more

computer operating-system LDDestroier github

Description

A collection of all my ComputerCraft programs and the APIs they use. This is mostly just to get them the fuck off of pastebin, and also to ensure that API owners don't change things to break my precious programs...!

Installation

Copy one of these commands into your ComputerCraft terminal:

wget:wget https://raw.githubusercontent.com/LDDestroier/CC/master/more.lua more
Archive:wget https://cc.shobie.xyz/cc/get/gh-LDDestroier-CC-more more
Quick Install: wget https://cc.shobie.xyz/cc/get/gh-LDDestroier-CC-more more

Usage

Run: more

Tags

none

Source

View Original Source

Code Preview

local allowedScrolls = 0

local tArg = {...}

if tArg[1] then
	local oldScroll = term.scroll
	term.scroll = function(lines)
		local scr_x, scr_y
		local evt, key
		if lines < 0 then
		 	oldScroll(lines)
		else
			for i = 1, lines do
				if allowedScrolls == 0 then
					evt, key = os.pullEvent("key")
					scr_x, scr_y = term.getSize()
					if key == keys.enter then
						allowedScrolls = scr_y - 1
					end
				else
					allowedScrolls = allowedScrolls - 1
				end
				oldScroll(1)
			end
		end
	end
	shell.run(tArg[1])
	term.scroll = oldScroll
else
	print("more [filename]")
end