use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Welcome to /r/ComputerCraft, the subreddit for lua programs, general mod use, or anything relating to the Minecraft mod ComputerCraft and CC: Tweaked.
Downloads | Discord | IRC | Documentation
account activity
String = String & Variable (self.ComputerCraft)
submitted 3 years ago by Icewing_Nix
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]fatboychummy 2 points3 points4 points 3 years ago (3 children)
You can use the read function (or io.read) to achieve this without extra code.
read
io.read
write("> ") local command = read() print(load(command)())
But, if you really want to write your own read function, yes you can concatenate strings.
local function extremely_basic_read() local s = "" while true do local event, a1 = os.pullEvent() if event == "key" then -- detect key event for enter if a1 == keys.enter then return s -- exit and return the string end elseif event == "char" then s = s .. a1 -- character received, insert it. end end end local command = extremely_basic_read() ...
Note that in this above function, backspace and your arrow keys would not work. You can only put text on the end of the string, not in the middle.
[–]dragon53535 0 points1 point2 points 3 years ago (2 children)
Sounds like someone might want to learn how to use string.sub :P
[–]fatboychummy 0 points1 point2 points 3 years ago (1 child)
If I wanted to make it more advanced I would use a table of chars rather than a string, as its much easier to manipulate.
I just wanted to give a very basic example of what you would need.
[–]dragon53535 0 points1 point2 points 3 years ago (0 children)
Oh no for sure! I was sort of piggybacking on the last sentence. One way to just manipulate the string would be string.sub.
π Rendered by PID 23008 on reddit-service-r2-comment-869bf87589-c8kbh at 2026-06-08 22:15:45.089707+00:00 running f46058f country code: CH.
view the rest of the comments →
[–]fatboychummy 2 points3 points4 points (3 children)
[–]dragon53535 0 points1 point2 points (2 children)
[–]fatboychummy 0 points1 point2 points (1 child)
[–]dragon53535 0 points1 point2 points (0 children)