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

Random text generator

Started by augiteSoul, 23 February 2017 - 02:49 PM
augiteSoul #1
Posted 23 February 2017 - 03:49 PM
Can someone make me a looping random text generator, with
characters ASCII 0 to 255? And it should work in the latest CC version for 1.7.10. Thanks.
All the ones I tried could not change the seed.
Lyqyd #2
Posted 23 February 2017 - 05:48 PM
Moved to General. Ask a Pro is where you'd ask for help when you get stuck creating something. There's no place on the forums to request that someone make something for you, but we usually stick these sort of posts in General.
TheRockettek #3
Posted 23 February 2017 - 07:03 PM

function randomLetter()
  return string.char(math.random(33,255)) -- 32 and below are control characters and other ones we dont need :^)
end

function generateString(number) -- cant be bothered to add checks for number to be a number.
  local str = ""
  for i=0,number,1 do
	str = str .. randomLetter()
  end
  return str
end


Edited on 26 February 2017 - 01:18 PM
augiteSoul #4
Posted 26 February 2017 - 08:27 AM

function randomLetter()
  return string.char(math.random(33,255)) -- 32 and below are control characters and other ones we dont need :^)
end

function generateString(number) -- cant be bothered to add checks for number to be a number.
  local str = ""
  for i,number do
	str = str .. randomLetter()
  end
  return str
end



Thanks, but i'm getting this error:
Spoiler
TheRockettek #5
Posted 26 February 2017 - 02:18 PM
Try now.
augiteSoul #6
Posted 02 March 2017 - 06:39 PM
Try now.
No error, but no output too.
Emma #7
Posted 03 March 2017 - 03:57 AM
What's your exact code? Because the code that TehRockettek posted should work.
TheRockettek #8
Posted 03 March 2017 - 08:07 AM
I believe you are using 1.7.10 minecraft which doesnt support certain characters?

Change
math.random(33,255)
to
math.random(33,122)
Lupus590 #9
Posted 03 March 2017 - 02:00 PM
TehRockettek's code doesn't print the string, it just makes it

add this to the bottom of Rocket's code

local length = 5
print(generateString(length))
Edited on 03 March 2017 - 01:01 PM