This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
shuffle's profile picture

Scrambled Text on monitors

Started by shuffle, 07 March 2013 - 09:21 AM
shuffle #1
Posted 07 March 2013 - 10:21 AM
I'm trying to have a monitor display some text and have some words scrambled like in the end credits after defeating the ender dragon. From searching around I've learned you need to place &k before the text to show this scrambled text in the chatbox. I tried the following code as a test

monitor = peripheral.wrap("bottom")
monitor.clear()
monitor.write("&kTest")
of coarse this doesn't work and just returns with "&kTest"

I've search the wiki and the forums and looking for a solution but have so far been unsuccesful.
Any help with this would be most appreciated.
Lyqyd #2
Posted 07 March 2013 - 11:07 AM
Split into new topic.

There is no way to do this; the monitors will display whatever you tell them to literally, within their capabilities. You'll need to scramble the text yourself.
LBPHacker #3
Posted 07 March 2013 - 11:48 AM
I'm sure there's an easier way to do this, but hey :D/> It's 11:52 PM here, I'm glad I'm still awake…



local scramble = function(theString)
	local outputTable = {}
	local scramblerTable = {}
	for i = 1, #theString do
		local char = string.sub(theString, i, i)
		local newID = false
		while (function()
			local inUse = not newID
			for key, value in pairs(scramblerTable) do inUse = (value == newID) or inUse end
			return inUse
		end)() do
			newID = math.random(1, #theString * 1000)
		end
		outputTable[newID] = char
		scramblerTable[#scramblerTable + 1] = newID
	end
	table.sort(scramblerTable, function(a, b ) return a < b end)
	local theOutput = ""
	for key, value in pairs(scramblerTable) do theOutput = theOutput .. outputTable[value] end
	return theOutput
end

print(scramble("Hello World"))