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

Random Choice add 1 to a variable

Started by Zeoic, 28 April 2012 - 10:50 PM
Zeoic #1
Posted 29 April 2012 - 12:50 AM
How would i go about making a program that would pick one word from a table and then add one to that variable.
Pretty much make a thing that when you type Mine it will print "You mined some (Random item here)!" And then it puts what yo must mined into your inventory (Variables).

Thanks
- Zeoic
Zeoic #2
Posted 29 April 2012 - 03:46 AM
Can someone please help me?
libraryaddict #3
Posted 29 April 2012 - 04:44 AM
If read() == "mine" then
mine = mine+1
end

Or you could use tables..

Table[MINE] = 0
Table[STONE] = 0
print("You can either use mine STONE or make MINE")
Pig = string.upper(read())
if Table[Pig] then
Table[Pig] = Table[Pig]+1
print("You "..Pig.."'ed and now you have another "..Table[Pig].."!")
end

The string.upper converts it to upper capitals.
Making sure they enter "MINE" even if they do "MinE"