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

custom OS help

Started by mesaif1337, 26 August 2012 - 04:42 PM
mesaif1337 #1
Posted 26 August 2012 - 06:42 PM
I was trying to create a kind of customOS with its own programs, and decided to make an extended "adventure" command, but im not actually sure how to make it so that lua chooses a random adventure to give to the player, and i need a bit of help on that, so thanks in advance, I guess.
Graypup #2
Posted 26 August 2012 - 09:41 PM
math.random(lowerlimit, upperlimit) *should* work. Basic layout should be: adventure content is in functions, called by an if statement running on random numbers. (local usedquest = math.random(*upperlimit*, 0) if usedquest == "blah" then *quest1*() elseif usedquest == "blah2" then *quest2*() end)
mesaif1337 #3
Posted 26 August 2012 - 10:02 PM
wait, so the adventure content, like "your in someplace and theres something and something blah blah blah" would be in functions like Adv1 = print("your in someplace and theres something and something blah blah blah") then say if theres 10 different ones of these, then each one is corresponding to a number, say math.random(9,0) and the if usedquest is the number it picked, then if usedquest == 1 then (Adv1). i think that makes sense, if it doesnt, i just want to know how to find out what number the math.random picked, then i just use if (number picked) == 1 then (Adv1) else if (number picked) == 2 then (Adv2) and so on, right. I'm really not sure if you can understand that, so if you dont get it, ill try to redo it, for now im leaving it.
immibis #4
Posted 27 August 2012 - 06:13 AM
wait, so the adventure content, like "your in someplace and theres something and something blah blah blah" would be in functions like Adv1 = print("your in someplace and theres something and something blah blah blah") then say if theres 10 different ones of these, then each one is corresponding to a number, say math.random(9,0) and the if usedquest is the number it picked, then if usedquest == 1 then (Adv1). i think that makes sense, if it doesnt, i just want to know how to find out what number the math.random picked, then i just use if (number picked) == 1 then (Adv1) else if (number picked) == 2 then (Adv2) and so on, right. I'm really not sure if you can understand that, so if you dont get it, ill try to redo it, for now im leaving it.


randomnumber = math.random(1,10)
if randomnumber == 1 then
 print("It was 1!")
elseif randomnumber == 2 then
 print("It was 2!")
-- etc
end